LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-29-2015, 01:12 PM   #1
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Rep: Reputation: 55
Is there a way to avoid 00's in these assembly lea instructions?


Is there a way to avoid 00's in these assembly lea instructions?

Code:
        lea rsi, [userpass]
        lea rdi, [passcode]
Here is the object dump:
Code:
  bc:	48 8d 34 25 00 00 00 	lea    rsi,ds:0x0
  c3:	00 
  cd:	48 8d 3c 25 00 00 00 	lea    rdi,ds:0x0
  d4:	00
 
Old 09-29-2015, 11:11 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
(If you are so desperate to become a haxor then please do some research on your own.)
 
Old 09-30-2015, 04:10 AM   #3
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Original Poster
Rep: Reputation: 55
So anyone who uses assembly is a hacker?
 
Old 09-30-2015, 04:25 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
Certainly not. However, considering the topics you have opened so far...
 
Old 09-30-2015, 04:28 AM   #5
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Original Poster
Rep: Reputation: 55
If you can hack a server with 2 lea statements, I'd like to see that.
 
Old 09-30-2015, 04:36 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
Well, it requires at least three LEA's and four XCHG's.

Nonetheless, its hard to believe that you want to disguise machine code as string-literal for benevolent reasons.
 
Old 09-30-2015, 08:13 AM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,670
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
The instructions are what the instructions are. Yes, they contain zeros, but if you really want to be a L33T H4X0R you will know how to disguise them by compression or run-length encoding.

But you will also find that, in most operating systems today, you cannot execute instructions out of the data segment, and you cannot modify the code segment.
 
Old 09-30-2015, 09:04 AM   #8
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by abefroman View Post
Is there a way to avoid 00's in these assembly lea instructions?

Code:
        lea rsi, [userpass]
        lea rdi, [passcode]
Here is the object dump:
Code:
  bc:	48 8d 34 25 00 00 00 	lea    rsi,ds:0x0
  c3:	00 
  cd:	48 8d 3c 25 00 00 00 	lea    rdi,ds:0x0
  d4:	00
I think those 00s are placeholders that will be replaced by the addresses of userpass and passcode when you link the object file.
 
Old 09-30-2015, 09:18 AM   #9
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Original Poster
Rep: Reputation: 55
Quote:
Originally Posted by ntubski View Post
I think those 00s are placeholders that will be replaced by the addresses of userpass and passcode when you link the object file.
relocation bytes?
 
Old 09-30-2015, 09:23 AM   #10
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
The object module contains a 'replace/overwrite section' that informs the linkers which bytes are to be replaced when external symbols are resolved.

Last edited by NevemTeve; 09-30-2015 at 09:24 AM.
 
Old 10-01-2015, 10:55 AM   #11
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,670
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
In this case, the construct ds:0x0 will require no relocation: the correct final-value is, "zero."

But, yes, that is how a linker works. The compiler specifies the locations where address-values will need to be plugged in, and the name of the symbol whose value must be put there. The compiler does not know what address-value the symbol will eventually have, and the linker must be told by the compiler where to insert them.

Last edited by sundialsvcs; 10-01-2015 at 10:56 AM.
 
Old 10-01-2015, 11:32 AM   #12
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by sundialsvcs View Post
In this case, the construct ds:0x0 will require no relocation: the correct final-value is, "zero."
I think the OP disassembled the object file, and the placeholder zero was interpreted by the disassembler as ds:0x0. It doesn't make sense that both (or even just one of) [userpass] and [passcode] would become zero in the final executable.

Last edited by ntubski; 10-01-2015 at 11:33 AM. Reason: add "(or even just one of)"
 
Old 10-01-2015, 05:15 PM   #13
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,670
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Indeed. I had failed to pick-up on that. Yes, what will usually be found in an object-file is either a zero, or the "offset," to which the symbol-address (once determined by the linker) is customarily added.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What's the difference between lea and mov in assembly? abefroman Programming 5 09-15-2015 07:57 AM
[SOLVED] Linux Assembly: write and receive assembly data errigour Programming 2 09-22-2012 09:54 AM
LXer: LPI announces Linux Training Program with the International Telecommunication Union in the Lea LXer Syndicated Linux News 0 03-07-2012 11:20 AM
among the assembly instructions...what is the LEA(load effective address)! gong.sncuse Programming 3 04-11-2011 12:47 AM
Assembly program runs 81 times *slower* with 13 fewer instructions. Travis86 Programming 11 11-15-2008 11:30 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration