This forum is in archive mode. You will not be able to post new content.

Author Topic: Shellcoding continues...  (Read 1437 times)

0 Members and 1 Guest are viewing this topic.

Offline parad0x

  • VIP
  • Royal Highness
  • *
  • Posts: 638
  • Cookies: 118
    • View Profile
Shellcoding continues...
« on: November 10, 2015, 10:22:32 PM »
Here's the part 2 of my previous tut HERE

I would recommend reading my previous tut before starting this one ;)

Moving on to mkdir shellcode, this shellcode creates a directory with permissions 777 means read, write and execute for all. :)

Algorithm
Make umask 0, then create a directory with permission 777 (in octal) and simply exit.

Now the question arises why did we make umask 0?
The answer lies in the functioning of mkdir, if you pass mkdir some permissions for creating a directory, it assigns the permission of the newly created directory to ~umask & (permission) so by making umask 0, ~umask = 11111111 (NOTE ; here every 1 corresponds to a bit),  which means whichever permission you give for the directory, they'll be applied as it is. Got it? Cool.. let's move your ass further. :D

I've removed all the nulls from the shellcode, made it PIC and here is the shellcode
Code: [Select]
\x31\xdb\xf7\xe3\xb0\x3c\xcd\x80\x31\xc9\x5b\xb0\x27\x66\xb9\xff\x01\xcd\x80\xb0\x01\xcd\x80\xe8\xe4\xff\xff\xff\x48\x61\x63\x6b\x65\x64
In assembly, it is
Code: (Assembly) [Select]
.text

.globl _start

shellcode:

xorl %ebx, %ebx
mull %ebx
movb $60, %al
int $0x80                                      # umask syscall on x86 system

xorl %ecx, %ecx
popl %ebx
movb $39, %al
movw $0777, %cx
int $0x80                                # mkdir syscall

movb $1, %al
int $0x80                               # Exit syscall

_start:
call shellcode
.asciz "Hacked"      # Name of the directory to be created

If you know assembly, the code is fairly self explanatory, if you're having problems understanding what the fuck I've given, go learn assembly  8)



After putting the shellcode in a C program, we verify it :D


Now you've create a directory with permission 777, go play with it ;)
« Last Edit: November 11, 2015, 03:21:17 AM by parad0x »

Offline blindfuzzy

  • VIP
  • Peasant
  • *
  • Posts: 86
  • Cookies: 34
    • View Profile
Re: Shellcoing continues...
« Reply #1 on: November 10, 2015, 10:36:14 PM »
You're missing the "d" in coding in your title.

Offline straycat

  • Serf
  • *
  • Posts: 28
  • Cookies: 7
    • View Profile
Re: Shellcoing continues...
« Reply #2 on: November 10, 2015, 11:11:49 PM »
I don't know assembly so it's till quite a bit over my head but seems nice. Where's the porn behind your terminals tho? I thought we had an agreement.

Offline parad0x

  • VIP
  • Royal Highness
  • *
  • Posts: 638
  • Cookies: 118
    • View Profile
Re: Shellcoing continues...
« Reply #3 on: November 11, 2015, 03:20:53 AM »
Sorry folks, it was like 3 in the morning and I was feeling sleepy.  :P

Offline blindfuzzy

  • VIP
  • Peasant
  • *
  • Posts: 86
  • Cookies: 34
    • View Profile
Re: Shellcoing continues...
« Reply #4 on: November 11, 2015, 05:35:23 PM »
I don't know assembly so it's till quite a bit over my head but seems nice. Where's the porn behind your terminals tho? I thought we had an agreement.

He opted out because he's a vag.

Offline parad0x

  • VIP
  • Royal Highness
  • *
  • Posts: 638
  • Cookies: 118
    • View Profile
Re: Shellcoing continues...
« Reply #5 on: November 11, 2015, 06:21:58 PM »
I don't know assembly so it's till quite a bit over my head but seems nice. Where's the porn behind your terminals tho? I thought we had an agreement.
I said I'll ask and then post those spicy backgrounds, re-read the logs. Btw Decepticon's logo is cool, don't you think so, it seems a bit misaligned but is quite perfectly aligned on the login screen.
« Last Edit: November 11, 2015, 06:24:47 PM by parad0x »

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.