Differences in disassembling 32 bit and 64bit












1















I started my adventure with reverse engineering but I have some problems which I can't solve from the very beginning. I'm following tutorials on YT and I meet some differences. So, when I work with this code from the tutorial:



#include <stdio.h>
#include <string.h>

int main(int argc, char** argv)
{
char buffer[500];
strcpy(buffer, argv[1]);

return 0;
}


I should get disassembly result as the guy from the tutorial:
expected result



But when I compile my program on a 32bit virtual machine withgcc -g -z execstack -fno-stack-protector and get result like this:enter image description here



When I compile the same same cod on 64bit virtual machine with gcc -g -z execstack -fno-stack-protector -m32 I get the same result. However if I compile it with gcc -g -z execstack -fno-stack-protector I get something like this:enter image description here



So it looks like the screenshot from the tutorial but it's 64bit version. So my question is, am I doing something wrong or I shoulg change something? I don't know if I should learn working with 64bit system or find a way to repair 32bit one. Anyone can help me?










share|improve this question























  • Try with -no-pie

    – Havenard
    Nov 12 '18 at 18:56











  • That call to get_pc_thunk tells it's position independent code according to this answer, so it might be the case why it is different. Disabling this feature at the compiler with -no-pie might make them look more alike. Also, the optimizer works in mysterious ways, disabling it with -O0 may also help you recognize your code once it gets transformed in assembly.

    – Havenard
    Nov 12 '18 at 19:00













  • But as you know my previous question, may it be the case why my payload doesn't work? Or it's just an appearance and has nothing to do with a shellcode and memory?

    – Shirakumo
    Nov 12 '18 at 19:03











  • As long as eip/rip overwrite the ret address of the function by the address of the shellcode or any of the x90 before it, the shellcode should work.

    – Havenard
    Nov 12 '18 at 19:05













  • The ret address of the function, in any function implemented using __cdecl (default calling convention of the C language) is at the address ebp-4 (32-bit) or rbp-8 (64-bit).

    – Havenard
    Nov 12 '18 at 19:07
















1















I started my adventure with reverse engineering but I have some problems which I can't solve from the very beginning. I'm following tutorials on YT and I meet some differences. So, when I work with this code from the tutorial:



#include <stdio.h>
#include <string.h>

int main(int argc, char** argv)
{
char buffer[500];
strcpy(buffer, argv[1]);

return 0;
}


I should get disassembly result as the guy from the tutorial:
expected result



But when I compile my program on a 32bit virtual machine withgcc -g -z execstack -fno-stack-protector and get result like this:enter image description here



When I compile the same same cod on 64bit virtual machine with gcc -g -z execstack -fno-stack-protector -m32 I get the same result. However if I compile it with gcc -g -z execstack -fno-stack-protector I get something like this:enter image description here



So it looks like the screenshot from the tutorial but it's 64bit version. So my question is, am I doing something wrong or I shoulg change something? I don't know if I should learn working with 64bit system or find a way to repair 32bit one. Anyone can help me?










share|improve this question























  • Try with -no-pie

    – Havenard
    Nov 12 '18 at 18:56











  • That call to get_pc_thunk tells it's position independent code according to this answer, so it might be the case why it is different. Disabling this feature at the compiler with -no-pie might make them look more alike. Also, the optimizer works in mysterious ways, disabling it with -O0 may also help you recognize your code once it gets transformed in assembly.

    – Havenard
    Nov 12 '18 at 19:00













  • But as you know my previous question, may it be the case why my payload doesn't work? Or it's just an appearance and has nothing to do with a shellcode and memory?

    – Shirakumo
    Nov 12 '18 at 19:03











  • As long as eip/rip overwrite the ret address of the function by the address of the shellcode or any of the x90 before it, the shellcode should work.

    – Havenard
    Nov 12 '18 at 19:05













  • The ret address of the function, in any function implemented using __cdecl (default calling convention of the C language) is at the address ebp-4 (32-bit) or rbp-8 (64-bit).

    – Havenard
    Nov 12 '18 at 19:07














1












1








1








I started my adventure with reverse engineering but I have some problems which I can't solve from the very beginning. I'm following tutorials on YT and I meet some differences. So, when I work with this code from the tutorial:



#include <stdio.h>
#include <string.h>

int main(int argc, char** argv)
{
char buffer[500];
strcpy(buffer, argv[1]);

return 0;
}


I should get disassembly result as the guy from the tutorial:
expected result



But when I compile my program on a 32bit virtual machine withgcc -g -z execstack -fno-stack-protector and get result like this:enter image description here



When I compile the same same cod on 64bit virtual machine with gcc -g -z execstack -fno-stack-protector -m32 I get the same result. However if I compile it with gcc -g -z execstack -fno-stack-protector I get something like this:enter image description here



So it looks like the screenshot from the tutorial but it's 64bit version. So my question is, am I doing something wrong or I shoulg change something? I don't know if I should learn working with 64bit system or find a way to repair 32bit one. Anyone can help me?










share|improve this question














I started my adventure with reverse engineering but I have some problems which I can't solve from the very beginning. I'm following tutorials on YT and I meet some differences. So, when I work with this code from the tutorial:



#include <stdio.h>
#include <string.h>

int main(int argc, char** argv)
{
char buffer[500];
strcpy(buffer, argv[1]);

return 0;
}


I should get disassembly result as the guy from the tutorial:
expected result



But when I compile my program on a 32bit virtual machine withgcc -g -z execstack -fno-stack-protector and get result like this:enter image description here



When I compile the same same cod on 64bit virtual machine with gcc -g -z execstack -fno-stack-protector -m32 I get the same result. However if I compile it with gcc -g -z execstack -fno-stack-protector I get something like this:enter image description here



So it looks like the screenshot from the tutorial but it's 64bit version. So my question is, am I doing something wrong or I shoulg change something? I don't know if I should learn working with 64bit system or find a way to repair 32bit one. Anyone can help me?







c reverse-engineering disassembly






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 18:36









ShirakumoShirakumo

324




324













  • Try with -no-pie

    – Havenard
    Nov 12 '18 at 18:56











  • That call to get_pc_thunk tells it's position independent code according to this answer, so it might be the case why it is different. Disabling this feature at the compiler with -no-pie might make them look more alike. Also, the optimizer works in mysterious ways, disabling it with -O0 may also help you recognize your code once it gets transformed in assembly.

    – Havenard
    Nov 12 '18 at 19:00













  • But as you know my previous question, may it be the case why my payload doesn't work? Or it's just an appearance and has nothing to do with a shellcode and memory?

    – Shirakumo
    Nov 12 '18 at 19:03











  • As long as eip/rip overwrite the ret address of the function by the address of the shellcode or any of the x90 before it, the shellcode should work.

    – Havenard
    Nov 12 '18 at 19:05













  • The ret address of the function, in any function implemented using __cdecl (default calling convention of the C language) is at the address ebp-4 (32-bit) or rbp-8 (64-bit).

    – Havenard
    Nov 12 '18 at 19:07



















  • Try with -no-pie

    – Havenard
    Nov 12 '18 at 18:56











  • That call to get_pc_thunk tells it's position independent code according to this answer, so it might be the case why it is different. Disabling this feature at the compiler with -no-pie might make them look more alike. Also, the optimizer works in mysterious ways, disabling it with -O0 may also help you recognize your code once it gets transformed in assembly.

    – Havenard
    Nov 12 '18 at 19:00













  • But as you know my previous question, may it be the case why my payload doesn't work? Or it's just an appearance and has nothing to do with a shellcode and memory?

    – Shirakumo
    Nov 12 '18 at 19:03











  • As long as eip/rip overwrite the ret address of the function by the address of the shellcode or any of the x90 before it, the shellcode should work.

    – Havenard
    Nov 12 '18 at 19:05













  • The ret address of the function, in any function implemented using __cdecl (default calling convention of the C language) is at the address ebp-4 (32-bit) or rbp-8 (64-bit).

    – Havenard
    Nov 12 '18 at 19:07

















Try with -no-pie

– Havenard
Nov 12 '18 at 18:56





Try with -no-pie

– Havenard
Nov 12 '18 at 18:56













That call to get_pc_thunk tells it's position independent code according to this answer, so it might be the case why it is different. Disabling this feature at the compiler with -no-pie might make them look more alike. Also, the optimizer works in mysterious ways, disabling it with -O0 may also help you recognize your code once it gets transformed in assembly.

– Havenard
Nov 12 '18 at 19:00







That call to get_pc_thunk tells it's position independent code according to this answer, so it might be the case why it is different. Disabling this feature at the compiler with -no-pie might make them look more alike. Also, the optimizer works in mysterious ways, disabling it with -O0 may also help you recognize your code once it gets transformed in assembly.

– Havenard
Nov 12 '18 at 19:00















But as you know my previous question, may it be the case why my payload doesn't work? Or it's just an appearance and has nothing to do with a shellcode and memory?

– Shirakumo
Nov 12 '18 at 19:03





But as you know my previous question, may it be the case why my payload doesn't work? Or it's just an appearance and has nothing to do with a shellcode and memory?

– Shirakumo
Nov 12 '18 at 19:03













As long as eip/rip overwrite the ret address of the function by the address of the shellcode or any of the x90 before it, the shellcode should work.

– Havenard
Nov 12 '18 at 19:05







As long as eip/rip overwrite the ret address of the function by the address of the shellcode or any of the x90 before it, the shellcode should work.

– Havenard
Nov 12 '18 at 19:05















The ret address of the function, in any function implemented using __cdecl (default calling convention of the C language) is at the address ebp-4 (32-bit) or rbp-8 (64-bit).

– Havenard
Nov 12 '18 at 19:07





The ret address of the function, in any function implemented using __cdecl (default calling convention of the C language) is at the address ebp-4 (32-bit) or rbp-8 (64-bit).

– Havenard
Nov 12 '18 at 19:07












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268159%2fdifferences-in-disassembling-32-bit-and-64bit%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268159%2fdifferences-in-disassembling-32-bit-and-64bit%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

さくらももこ

13 indicted, 8 arrested in Calif. drug cartel investigation