Saturday, February 27, 2010
Friday, February 19, 2010
Shady URL
http://5z8.info/mercenary_z9u8_IE-exploiter
http://5z8.info/stalin_s6c2_friendster-of-sex
Saturday, February 13, 2010
What is in the heap?
Google is a sharp cookie
Saturday, January 30, 2010
Privacy and Relevance
The best advertising I’ve seen online is:
* Popups that open up all over the place, opening new windows when I try to close them
* Ads that tell me I have won a million dollars by the virtue of being visitor number XXXXXX, or the ones that mimic a Windows alert dialog telling me my infected computer needs to be purged of its virii
* In text links that popup a window when the mouse moves over them even by mistake (or video ads that start playing for the same reason)* All of the above
No points for guessing that I am kidding. Never would anyone ask a question that honest. They asked this instead.
The best advertising I’ve seen online :
* Provides useful information and content* entertains me with video and sound* appears before a page loads* allows me to interact with the adAs a self proclaimed online advertising expert, I went ahead and choose the third option (appears before a page loads). But the 118 people who had chosen to answer begged to differ
* Ads that tell me I have won a million dollars by the virtue of being visitor number XXXXXX, or the ones that mimic a Windows alert dialog telling me my infected computer needs to be purged of its virii
* In text links that popup a window when the mouse moves over them even by mistake (or video ads that start playing for the same reason)
The best advertising I’ve seen online :
* Provides useful information and content* entertains me with video and sound* appears before a page loads* allows me to interact with the adAs a self proclaimed online advertising expert, I went ahead and choose the third option (appears before a page loads). But the 118 people who had chosen to answer begged to differ

Now what good I would be as an expert if my opinion was the same as the masses? Jokes apart, the results of this poll reflect our infatuation with metrics, and one unfortunate tradeoff. Surely, "You can't manage what you can't measure" makes for a great quote, and the ability to measure performance is one of the USP's of our industry, but this obsession has done us a great deal of harm. First, because going by the metrics that we commonly employ - all the tactics I presented as the options for the non existent linkedin poll at the start of this post, and which would make the most even the greatest fanboys of online advertising turn in their graves (there are no fanboys of online advertising - hence the grave example), will be counted among the best performing advertising seen online. They all enjoy a very high click through rate, appear to be more engaging than anything else for the advertiser, and generate more revenue for the publishers who run them. But more importantly, everyone seems to miss the tradeoff between privacy and relevance. In order that we target you better than we currently do, we need to know more about you, and that does require you giving up some of your privacy. We need to know what is 'useful information' - because one man's useful information can be another man's ... Okay, okay - no more cliches for you now.
Tuesday, January 26, 2010
iPhone and advertising
AdMob clarified this via email recently saying, “as our iPhone app download tracking relies on unique user information, it only functions for ads shown within applications.”
Wednesday, January 13, 2010
Inspect Element
I work in the online ad industry, and while you may hate even looking at the banner ads, I am often tasked with finding out who is running that banner ad. With aggregators, meta-aggregator, networks and exchanges, it is increasingly difficult to tell who is running on which site, and you need to check.
You can always hover/click on the ad and hope to be able to be fast enough to notice the redirect, but this would often not work with flash content/javascript based clicks. Or you can run a monitoring tool like Firebug or HttpWatch and look at the http request/response for that page, it is too clumsy - Firebug is painfully slow to have it running all the time, so running it means one has to refresh the page after the ad has been loaded. I usually find the 'Inspect Element' option (shown when you right click) very handy. It lets you inspect the page source (not the static source but the generated one, in all its glory, and takes you right away to the element of interest, under the hood. Like all good things, it is a Firefox only option, and one of the things that ensured I couldn't really switch from Firefox to Camino or Safari even when I want to.

The good news is, this option is available on Safari too, although it is hidden. To enable it, fire up a terminal window and issue this command
defaults write com.apple.Safari WebKitDeveloperExtras -bool true
That's it. When you restart Safari next, you would see the Inspect Element option when your right click anywhere on page, and should you exercise that option, you would be greeted with a pane like the one below

Monday, June 22, 2009
Saturday, May 23, 2009
Overriding a system call in AIX
I went through your blogs..quite nice..
I need some help with the aix kernel.I m currently implement a system call.
What I need to do is basically intercept a system call on aix 5.3.
How can I do this.?.
On linux I have the system call table , which i can replace the current system calls with my own using the NR offset into the sys_call_table.
How do i do the same in aix kernel?
AIX is a different beast altogether, unlike a lot of other Unixes, because its BSD heritage is not as strong and a bit under the hood. So a lot of things work very differently in AIX, and over-riding a system call is one of them.
For the impatient, here is a short answer.
Write a function with the same signature as the system call and load it as a kernel extension. Any application started after this new module has been loaded will see your symbol as a system call, instead of the original one, due to the way AIX loader works.
For most of the time - you are interested in intercepting a system call, rather than overriding it. Let's say you want to intercept getpid(). Now you could write your own version of getpid with an exactly same signature, do whatever you wanted to do, and then transfer control to the original getpid(). IBM has an example here on how could you add a new syscall to AIX.
Follow it, but name your syscall getpid() (or whatever you want to override).
Herein lies the catch. There is no way you can call the original getpid(), because just having overridden that symbol, you can no longer access the original. Any attempts to call getpid() from with getpid() will result in ...
Well, what else, but recursion.
So to work around this problem, over-riding a system call means writing two kernel modules. The first one would merely re-export the original system call with a different name. The second, will actually override the syscall by redefining it, and then call the original one as exported by the first module. To make it cleaner, you can automate the loading of the first module from within the second module, so to the user, it is only one module that they load.
Usually you would do this fairly early on in the boot process, because your intercept will not apply to applications started before the interceptor module was loaded.
I will update this post sometime in the future with the long answer.
Tuesday, February 03, 2009
Null Pointer on AIX
#include
int main() {
int *a = 0;
int b = *a;
printf("hello world\n");
return 0;
}
What will the output be. Will it ever get to say hello ? In most worlds other than IBM's, it won't.
But AIX has its own idiosyncracies. So the qualified answer is, "it depends"
Here is what a very old text I found had to say (This was from AIX 3.2 times)
9.1. Derefencing NULL PointersSo that explains it. On AIX, at least till version 5.3, you can
The word at memory location zero contains a zero.
That means that code which has been incorrectly
written to use a NULL pointer to represent a null
string will work, but will not be portable to all
UNIX operating systems, and may not work on future
AIX systems.
dereference a null pointer, and get away with it :)
Here is the link to the original document , for more such trivia. Would post more of these later, need to get back to work.
http://www.rootunix.org/AIX/325bsdpo.txt
Fine Print: This is a repost. I have now decided to use thruput as my only blog, giving up on http://360.yahoo.com/mqzaidi/blog. You would see some old content resurrected from that blog here.
Thursday, September 27, 2007
Wednesday, August 29, 2007
Set Term Title
To work around, add this to your remote .bashrc
if [ -n "$PS1" ]; then
echo -n -e "\033]0;`hostname`\007"
fi
The PS1 check is just to ensure that in non-interactive sessions (such as the one started by rsync), the echo doesn't corrupts the stream.
Wednesday, April 11, 2007
dbx for gdb users
dbx has a gdb mode. It supports most gdb commands. To turn it on, at the dbx prompt, type this
(dbx) gdb on
And as usual, this can be automated by creating a .dbxrc and putting 'gdb on' there.
Now all the gdb commands such as c, b, i can be used.
If you want to step over a few lines of code without recompiling, use cont at
(dbx) cont at 221
will continue the program at line 221, skipping all the code between current line and 221.
r doesn't works for run though, and thats because its already set as an alias to something else.
(dbx) alias
[='\['
alias='kalias'
commands='paged-commands'
echo='kprint'
functions='typeset -f'
help='paged-help'
integer='typeset -i'
lo='loadobject'
nohup='nohup '
pp='prettyprint'
pwd='kprint -r "$PWD"'
r='fc -e -'
sh='sh-cmd'
suspend='kill -STOP $$'
type='whence -v'
But if you wish, you can redefine it to run
(dbx) alias r run
(And to make this permanent, put it in .dbxinit)
dbx also supports histories, accessed as usual using history and !!.
Conditional breakpoints are also supported. To set one, first set a normal breakpoint, e.g.
(dbx) b code.c:2197
(dbx) i b
[1] stop at "code.c":2197
and then make it conditional
(dbx) cond 1 'codePtr->id==12'
(dbx) cond
That's it, for this post.
Wednesday, January 17, 2007
Zen and the art of iCal sync
- Export the ics file from the application (iCal, Mozilla or Google Calendar)
- Send the ics to the zen using mtp-sendfile
$mtp-sendfile ~/Home.ics Home.ics (The second argument is destination filename)
Sunday, January 14, 2007
Creative Zen Vision on Mac (Darwin)
Here is some interesting news on MTP from wikipedia, though
Media Transfer Protocol is a set of custom extensions to the Picture Transfer Protocol (PTP) devised by Microsoft, to allow the protocol to be used for devices other than digital cameras, for example digital audio players such as MP3 players, and other portable media devices, for example portable video players.
The USB Implementers Forum device working group is presently working on standardizing MTP as a fully fledged Universal Serial Bus (USB) device class. When that process is complete, MTP will be a USB device class peer to USB mass storage device class, USB Video Class, and so on.
Since that standardisation would take some time, and I suddenly had some free time on hand on fine sunday morning, I decided to try and see what we can still get to work on darwin.
To begin with, I downloaded the libmtp library from sourceforge, which fortunately enough supports mac already and didn't needed any porting, except for an iconv issue. The problem with libiconv is (which is , btw, a library for converting from one charecter set encoding to the other) that there are simply too many versions floating around. So while libmtp compiles and installs fine, any of the example programs won't run, failing with missing symbols.
That was easily fixed though, by adding -liconv to the Makefile in the examples directory in the libmtp sources. (Search for LIBS = -lusb and append -liconv). With this change, running mtp-detect (which installs in /usr/local/bin) gives this output
Autodetected device "Creative Zen Vision:M" (VID=041e,PID=413e) is known.
Connected to MTP device.
USB low-level info:
bcdUSB: 512
bDeviceClass: 255
bDeviceSubClass: 0
bDeviceProtocol: 0
idVendor: 041e
idProduct: 413e
IN endpoint maxpacket: 512 bytes
OUT endpoint maxpacket: 512 bytes
Device flags: 0x00000000
Device info:
Manufacturer: Creative Technology Ltd
Model: Creative Zen Vision:M
Device version: 1.30.02_0.00.16
Serial number: 00023C02FB1FE532E960B05763D234C3
Vendor extension ID: 0x00000006
Vendor extension description: microsoft.com: 1.0;microsoft.com/WMPPD: 10.0;mi
crosoft.com/WMDRMPD: 10.1;
Supported operations:
1001: get device info
1002: Open session
1003: Close session
...
...
Quite a lot of it actually, but here is the more relevant part
3009: MP3
de99: AudioWAVECodec
de9a: AudioBitRate
dc46: Artist
dc89: Duration
dc8b: Track
dc8c: Genre
dc99: OriginalReleaseDate
dc9a: AlbumName
de93: SampleRate
de94: NumberOfChannels
de95: AudioBitDepth
dc91: UseCount
dc8a: Rating
d901: BuyFlag
dc01: StorageID
dc0b: ParentObject
dc02: ObjectFormat
dc04: ObjectSize
dc07: ObjectFileName
dc41: PersistantUniqueObjectIdentifier
dc4f: NonConsumable
dc44: Name
b901: WMA
...
3008: MS Wave
ba05: Abstract Audio Video Playlist
ba01: Abstract Multimedia Album
ba03: Abstract Audio Album
3801: JPEG
300a: MS AVI
300c: ASF
b982: MP4
300b: MPEG
b981: WMV
bb83: vCard3
be03: vCalendar2
3000: Undefined Type
3001: Association/Directory
b802: Firmware
Quite a few formats there.
Unix 101 - Tip
You have a program that creates a file, writes to it and deletes it later. You want to read that file before its deleted. How do you do that? I have been through such situations in the past, and my crude solution often involved writing a shell script that would keep polling for the existence of the file and then copy it, if it exists. Now here is the Unix way of doing this (I found this in imake faq)
Lets say the name of the transient file is xyz. This is what you do
$ touch fake
$ ln fake xyz
Now run the program that creates xyz. When it tries to remove it, since a hard link exists, it wouldn't be able to do so, and you can access the file afterwards !!
Reminds me of the dead.letter and sendmail exploit. Hard links are fun :))
Thursday, May 11, 2006
AIX Kernel Debug - II
The AIX kdb pages [link] list three different ways in which you can view kernel data from userspace. If its global data, and has been duly exported with a .exp file at link time, then its as simple as using the variable name. However, since global data is not usually exported this way, and we do not want to recompile a module just to debug, we would look at the other options.
Both the other methods require using a mapfile. A mapfile is a list of symbols in the kernel module, and their addresses (only relative), that can be generated while linking the module ( using the
-bloadmap:{mapfile} option.)Once that is done, this is how a mapfile looks like
*IE ADDRESS LENGTH AL CL TY Sym# NAME SOURCE-FILE(OBJECT) or IMPORT-FILE{SHARED-OBJECT}
--- -------- ------ -- -- -- ----- ------------------------- -------------------------------------------------
I ER S1 getgidx /lib/syscalls.exp{/unix}
I ER S2 getuidx /lib/syscalls.exp{/unix}
I ER S3 _system_configuration /lib/syscalls.exp{/unix}
...
...
000007A4 PR LD S58 <.qlog_write>
000007E4 PR LD S59 .qlog_disable_console_logging
00000824 PR LD S60 .qlog_enable_console_logging
00000864 PR LD S61 .qlog_get_log_types
...
... 000033DC 000004 2 TC SD S506 <> 000033E0 0001EC 3 RW CM S507 g_qlog_cntl qlog.c(qlib.lib) 000035CC 000004 2 RW CM S508 kern_config kernel_config.c(kconf.lib) 000035D0 00002C 3 RW CM S509 <_$static_bss> sc_dnlc.c(dnlc.lib)
000035FC 000004 2 RW CM S510 workflow_id kernel_config.c(kconf.lib)
Understandably, there are several classes of symbols in this file, indicating program code, glues, readonly and readwrite data. The PR LD or the GL LD class indicates program code or glue code, and is the text segment. The offsets that appear here are relative to the offset of the program entry point, which you specified as -binit:{ entrypoint } while linking.
So if you know the load address of the entry point, you can calculate the addresses for each function. And the lke command lets you do that, in kdb
(0)> lke
ADDRESS FILE FILESIZE FLAGS MODULE NAME
1 024F8000 02A1C000 0000F6E0 00000242 /usr/local/solidcore/s3/modules/scdrv
2 024F8F00 029D6000 00009348 00000252 random32/usr/lib/drivers/random
3 0219DF00 029B6000 000009AC 00100248 /unix
4 024F8E00 0286A000 001229D0 00000252 nfs.ext32/usr/lib/drivers/nfs.ext
So to find out where scdrv loads, Use the number that appears in the first coloum
(0)> lke 1
ADDRESS FILE FILESIZE FLAGS MODULE NAME
1 024F8000 02A1C000 0000F6E0 00000242 /usr/local/solidcore/s3/modules/scdrv
le_flags....... TEXT DATA DATAEXISTS
le_next........ 024F8F00 le_lex......... 00000000
le_fp.......... 00000000 le_fh.......... 00000000
le_file........ 02A1C000 le_filesize.... 0000F6E0
le_data........ 02A280D8 le_datasize.... 00003608
le_ldr......... 02A2C000 le_ldr_size.... 0x1141 (4417)
le_exports..... 00000000 le_entrypoint.. 02A2B268
le_usecount.... 1 le_loadcount... 1
le_ndepend..... 1 le_maxdepend... 1
le_filename.... 024F8060 le_depend.... @ 024F805C
TOC@........... 02A2B34C
process trace backs
.scdrv 02A1C160 .scdrv_fini 02A1C2A0
This address, when added to the relative addresses in the map file, gives us the load location of the functions.
Monday, March 20, 2006
Relinking binaries
The ld command can relink a program without requiring that you list all input object files again. For example, if one object file from a large program has changed, you can relink the program by listing the new object file and the old program on the command line, along with any shared libraries required by the program.
AIX is THE only Unix that can do that. Doesn't that means limitless possibilities ? It turns the whole idea of binary editing upside down. As an example, let us say we have a "test" program consisting of 2 different functions main and testfn, contained in main.c and testfn.c.
I want to override testfn. I can do that so easily, by writing testfn in a new file, say newfn.c and relinking the binary.
$ xlc -o test newfn.c test
Can we use this to extract code from binaries ? Don't know, lets figure out.
Wednesday, January 18, 2006
AIX Crash dumps - II
In kdb, you first need to tell kdb the header that defines your structure. In case of struct vnode, its sys/vnode.h. So we invoke kdb as
# kdb -i /usr/include/sys/vnode.h
and issue the print command
0>print vnode address
Which should print something like
struct vnode {
ushort v_flag = 0x0000;
ushort v_flag2 = 0x0000;
ulong32int64_t v_count = 0x00000000;
int v_vfsgen = 0x00000000;
union Simple_lock {
simple_lock_data _slock = 0x00000000;
struct lock_data_instrumented *_slockp = 0x00000000;
} v_lock;
struct vfs *v_vfsp = 0x31349808;
struct vfs *v_mvfsp = 0x00000000;
struct gnode *v_gnode = 0x13C823E0;
struct vnode *v_next = 0x00000000;
struct vnode *v_vfsnext = 0x13987F38;
struct vnode *v_vfsprev = 0x13D1AAE8;
union v_data {
void *_v_socket = 0x00000000;
struct vnode *_v_pfsvnode = 0x00000000;
} _v_data;
char *v_audit = 0x00000000;
} foo[0];
AIX crash dumps
Step 1:
OK, so when the system panics, you will hear the periodic beeps typical of the RS/6000 (if you are sitting close by). The beeps would go on as the machine dumps core, and if you do not want a core and have a slow machine, you could better restart by pressing the system reset button on the machine
[ There is a Step 0: where you make the system panic, but the details are left as an excercise to the reader :). See sysdumpstart(1) for more details. ]
Step 2:
When the system now boots, it may prompt you about saving the core dump before going into normal boot process. If you have a place to save ( a spare partition) , do save the dump here, or else press 99 to continue.
[ All of this depends on your configuration. Running sysdumpdev will allow you to examine and alter your dump settings. The Primary dump device is /dev/hd6 by default, which is also the AIX paging volume. Other settings include compression and ... (well, RTFM) ]
Step 3: (If you pressed 99 in last step, or else skip)
Now when the system is up, you use savecore -f /directory_path to save the core in a specific place. This would leave you a compressed .Z file, and a kernel image.
Step 4:
Uncompress the core using gunzip.
Step 5:
Run kdb as
# kdb vmcore.1 vmunix.1
And you would get something like this from kdb in return
19) mirdd [5 entries]
20) kbddd [2 entries]
21) mousedd [2 entries]
Component Dump Table has 913 entries
START END
0000000000001000 0000000002147040 start+000FD8
000000002FF3B400 000000002FF80A98 __ublock+000000
000000002FF22FF4 000000002FF22FF8 environ+000000
000000002FF22FF8 000000002FF22FFC errno+000000
00000000E0000000 00000000F0000000 sys_resource+000000
PFT:
id....................0004
raddr.....0000000000C00000 eaddr.....0000000000C00000
size..............00000000 align.............00000000
valid..1 ros....0 fixlmb.1 seg....1 wimg...2
PVT:
id....................0002
raddr.....0000000001000000 eaddr.....0000000001000000
size..............00000000 align.............00000000
valid..1 ros....0 fixlmb.1 seg....1 wimg...2
Dump analysis on POWER_PC POWER_604 machine with 1 available CPU(s) (32-bit registers)
Processing symbol table...
.......................done
Step 6:
Now we would see what really caused the panic. Run stat, and you will get some info on the machine and the core
(0)> stat
SYSTEM_CONFIGURATION:
POWER_PC POWER_604 machine with 1 available CPU(s) (32-bit registers)
SYSTEM STATUS:
sysname... AIX
nodename.. fundu
release... 3
version... 5
build date Apr 10 2005
build time 21:52:04
label..... yes
machine... 00081AAA4C00
nid....... 081AAA4C
time of crash: Wed Jan 18 04:29:05 2006
age of system: 15 hr., 52 min., 38 sec.
xmalloc debug: disabled
And the real thing, a backtrace of the function call
CRASH INFORMATION:
CPU 0 CSA 2FF3B400 at time of crash, error code for LEDs: 30000000
pvthread+004D80 STACK:
[0000A5E0].test_and_set+000020 ()
[00215020]slock_ppc+000320 (??, ??)
[00009554].simple_lock+000054 ()
[001F52A4]j2_rename+000140 (??, ??, ??, ??, ??, ??, ??)
[029CC17C]sc_vop_rename+000088 (??, ??, ??, ??, ??, ??, ??)
[002F8D54]vnop_rename+0000DC (??, ??, ??, ??, ??, ??, ??)
[0033C4C4]rename+00035C (2FF22DD3, 2FF22DE2)
[00003AD8].sys_call+000000 ()
[kdb_get_memory] no real storage @ 2FF226C8
There are more steps, which would be added after I am done with the debugging of the core at hand.
[ As a sidenote: The stat command is also the AIX equivalent of dmesg, which you would certainly miss, if you have used other unixes, such as Linux and HP-UX. It would show you the last few kernel printfs, still in memory, and that includes messages generated using bsdlog ]









