| Author |
How to Program directly in hex |
onejerlo
Member

Posts: 145
Location:
Joined: 02.11.08 Rank: Elite |
|
I wish to learn assembly mainly for cracking and editing programs.
However, I do not wish to get caught up in assemblers (since I do not wish to make large(or even medium sized) programs,this should not trouble me much).
While browsing through the net,I came across a few tutorials showing the procedure to change programs using Hex editors.
I searched for tutorials and info showing how to make programs using only a hex-editor but found little material about this.
(I really liked http://www.sudowudo.com/index.php?page=1012)
Any help would be greatly appreciated.
Edited by onejerlo on 17-05-10 13:18 |
|
| Author |
RE: How to Program directly in hex |
wolfmankurd
Member

Posts: 1519
Location: UK
Joined: 30.05.05 Rank: God |
|
|
EB 0E 48 65 6C 6C 6F 57 6F 72 6C 64 21 0A 0D 24
B4 09 BA 02 01 CD 21 CD 20 CD 10
Try that as hex in a file with a .com extension. If it works then I fucking rawk!
here's a break down.
EB 0E (jmp 14 - we are about to define the string next which can't be executed!)
48 65 6C 6C 6F 57 6F 72 6C 64 21 0A 0D 24 (HelloWorld!\n\r$, $ is liek a null it ends the string)
B4 09 (the service for string=>STDOUT)
BA 02 01 (The location of the string. 100=EB, 101=0E, 102 is the start of the string.)
CD 21 (cd is int 21 is the dos interupt we want)
CD 20 (I think this returns to loader)
CD 10 (kills program?)
I may have the last two interupts the wrong way around (they are dos specific and I last used dos interupts nearly 5 years ago) as well as the \r\n
it just occured to me that I don't need \r since this is for DOS but it was force of habit!
Best way to learn? Sit down with a x86 opcode book. Then practice without being able to define locations you need to memorise them or predict them I have to make sure my string was 14 characters long so the jmp would work. then I had to guess the location of the string was 102 then break it up to little endiand 20 01 too much work. stick with an assembler.
BY READING MY POST, YOU ACCEPT IT AS IS AND AGREE TO MY DISCLAIMER OF ALL WARRANTIES, EXPRESS OR IMPLIED, AS WELL AS DISCLAIMERS OF ALL LIABILITY, DIRECT, INDIRECT, CONSEQUENTIAL OR INCIDENTAL, THAT MAY ARISE FROM THE USE OF THIS (MIS)INFORMATION.

Edited by wolfmankurd on 17-05-10 20:36 |
|
| Author |
RE: How to Program directly in hex |
986
Member

Posts: 45
Location: Hungary
Joined: 18.01.08 Rank: Hacker Level 2 |
|
http://en.wikipedia.org/wiki/Comparison_of_hex_editors - choose one.
But you should learn about debuggers, like OllyDbg ( http://www.ollydbg.de/ )... |
|
| Author |
RE: THANKS!!! |
onejerlo
Member

Posts: 145
Location:
Joined: 02.11.08 Rank: Elite |
|
@wolfmankurd: Thanks,but using a hex editor reduces the work load a lot,you don't have to guess the location of the string or convert it(it shows you both)...however,I shall also try out an assembler(It is more comfortable ).
And it doesn't work(I may have committed some mistake...it executes,but there's no hello world...)
@986: I have several hex editors and know how to use a debugger(basics),as with any other beginner,my fav. is Olly Dbg.,but thanks anyway. |
|
| Author |
RE: How to Program directly in hex |
wolfmankurd
Member

Posts: 1519
Location: UK
Joined: 30.05.05 Rank: God |
|
Are you on windows? DEBUG is built in and lets you code in asm dissemble edit and run.
In your hex editor make a new file paste that in as hex (not ascii) then save it as "test.com"
It should work, I've just tested it.
It needs to be a com file not an exe as a com file is pure code, an exe has a header etc.
It's possible com files are no longer supported in new versions of windows especially 64bit versions.
A quick check bought up over 330 (there are probably quiet a few more including the add on sets) instructions. There is many more opcodes (some instructions have different op codes).
Memorising these will allow you to code using only a hex editor but you skill will be useless outside of your architecture even if you overcome the problem with labels.
BY READING MY POST, YOU ACCEPT IT AS IS AND AGREE TO MY DISCLAIMER OF ALL WARRANTIES, EXPRESS OR IMPLIED, AS WELL AS DISCLAIMERS OF ALL LIABILITY, DIRECT, INDIRECT, CONSEQUENTIAL OR INCIDENTAL, THAT MAY ARISE FROM THE USE OF THIS (MIS)INFORMATION.

Edited by wolfmankurd on 18-05-10 16:20 |
|
| Author |
RE: How to Program directly in hex |
onejerlo
Member

Posts: 145
Location:
Joined: 02.11.08 Rank: Elite |
|
@wolfmankurd:
YAY!!!It works and you Rawk .lI think I should stick to an assembler while learning after all... |
|
| Author |
RE: How to Program directly in hex |
wolfmankurd
Member

Posts: 1519
Location: UK
Joined: 30.05.05 Rank: God |
|
onejerlo wrote:
@wolfmankurd:
YAY!!!It works and you Rawk  .lI think I should stick to an assembler while learning after all...
=D yay! I always suspected I rawk lmao.
BY READING MY POST, YOU ACCEPT IT AS IS AND AGREE TO MY DISCLAIMER OF ALL WARRANTIES, EXPRESS OR IMPLIED, AS WELL AS DISCLAIMERS OF ALL LIABILITY, DIRECT, INDIRECT, CONSEQUENTIAL OR INCIDENTAL, THAT MAY ARISE FROM THE USE OF THIS (MIS)INFORMATION.

|
|