how to print an assembly value?

Put your programming skills to the test in these challenges.

how to print an assembly value?

Post by ghostheadx2 on Thu May 21, 2015 11:49 pm
([msg=88145]see how to print an assembly value?[/msg])

So, I need to print an assembly value. I don't know any assembly, but its for a reverse engineering challenge. I found this forum post on how to do it and couldn't apply anything I was learning:

http://stackoverflow.com/questions/1922134/printing-out-a-number-in-assembly-language

I think the first result is the right one, but I'm not sure.

Here's the online assembler I'm using:

https://ideone.com/e0B8yU

So, I want to be able to print a value to screen. I think its a number but I'm not sure. I want to know so I can get a flag for the reverse engineering challenge. Basically, I'm trying the different challenges categories in the CTF so I can get some points. I need to print a value to get the flag.
ghostheadx2
Contributor
Contributor
 
Posts: 728
Joined: Wed Nov 19, 2014 1:19 am
Blog: View Blog (0)


Re: how to print an assembly value?

Post by ghost107 on Fri May 22, 2015 12:45 am
([msg=88146]see Re: how to print an assembly value?[/msg])

If the operating system is linux you can use the system calls by using the int 80h:
http://www.informatik.htw-dresden.de/~b ... _list.html
Code: Select all
mov edx, len
mov ecx, msg
mov ebx, 1 ; file descriptor for stdout
mov eax, 4 ; sys_write call number (for 32-bit)
int 80h

Here is an example:
http://asm.sourceforge.net/intro/hello.html

On the example you posted from the stackoverflow uses int 21h which is a MS-DOS interrupt calls(only works on DOS and windows operating system):
http://en.wikipedia.org/wiki/MS-DOS_API

Also int 10h is a BIOS interrupt call:
http://webpages.charter.net/danrollins/ ... p/0113.HTM
User avatar
ghost107
Poster
Poster
 
Posts: 321
Joined: Wed Jul 02, 2008 7:57 am
Blog: View Blog (0)


Re: how to print an assembly value?

Post by ghostheadx2 on Fri May 22, 2015 12:39 pm
([msg=88148]see Re: how to print an assembly value?[/msg])

Actually, I decided I want to convert it into C language, to make it easier to read. I'm having trouble using this decompiler.

https://retdec.com/decompilation/

The problem is it gives me this error:

Code: Select all
The input file seems to be a text file. We only support decompilation of binary files. If you want to compile a C source code into a binary file and then decompile it, use the "C Code" input type instead.


Lol. How sad that I thought I had to do it in pure assembly because it was an assembly file.
ghostheadx2
Contributor
Contributor
 
Posts: 728
Joined: Wed Nov 19, 2014 1:19 am
Blog: View Blog (0)


Re: how to print an assembly value?

Post by cyberdrain on Mon May 25, 2015 2:04 pm
([msg=88179]see Re: how to print an assembly value?[/msg])

So instead of taking this as a reason to look some more into ASM you decided to take the easy route :P Remember, usually only C code compiled the 'right' way for your decompiler will decompile correctly.
Free your mind / Think clearly
User avatar
cyberdrain
Expert
Expert
 
Posts: 2160
Joined: Sun Nov 27, 2011 1:58 pm
Blog: View Blog (0)


Re: how to print an assembly value?

Post by ghost107 on Mon May 25, 2015 2:15 pm
([msg=88180]see Re: how to print an assembly value?[/msg])

ghostheadx2 wrote:Actually, I decided I want to convert it into C language, to make it easier to read. I'm having trouble using this decompiler.

https://retdec.com/decompilation/

The problem is it gives me this error:

Code: Select all
The input file seems to be a text file. We only support decompilation of binary files. If you want to compile a C source code into a binary file and then decompile it, use the "C Code" input type instead.


Lol. How sad that I thought I had to do it in pure assembly because it was an assembly file.

You would need to input a binary file, so you would need to assemble the assembly file and then link it into a executable (EXE or ELF).

Or input it with the C-code and the site will compile and decompile it.
User avatar
ghost107
Poster
Poster
 
Posts: 321
Joined: Wed Jul 02, 2008 7:57 am
Blog: View Blog (0)


Re: how to print an assembly value?

Post by ghostheadx2 on Tue May 26, 2015 11:54 pm
([msg=88200]see Re: how to print an assembly value?[/msg])

ghost107 wrote:Or input it with the C-code and the site will compile and decompile it.


So then, how do I do that? It seems like if I don't have C-code to begin with then I can't do that. Anything I should Google further at this point?
ghostheadx2
Contributor
Contributor
 
Posts: 728
Joined: Wed Nov 19, 2014 1:19 am
Blog: View Blog (0)


Re: how to print an assembly value?

Post by Turn on Wed May 27, 2015 12:14 am
([msg=88201]see Re: how to print an assembly value?[/msg])

ghostheadx2 wrote:Anything I should Google further at this point?


"Assembly Tutorial"
Social Engineering:
<cen> .lua print ('Tsyn 9.47.-u 3 12 5')
* slickery has quit (User has been banned from HackThisSite (Attempting to use a SpyBot))
* cen has quit (User has been banned from HackThisSite (Attempting to use a SpyBot))
User avatar
Turn
Poster
Poster
 
Posts: 120
Joined: Tue Feb 17, 2015 5:42 am
Blog: View Blog (0)


Re: how to print an assembly value?

Post by ghostheadx2 on Wed May 27, 2015 10:24 am
([msg=88206]see Re: how to print an assembly value?[/msg])

An assembly tutorial is needed for conversion? Hmm? I thought there were programs where you just input the code and it converted. Its not that simple I guess. Could someone please give me some help with understanding whatever I need to learn from the tutorial?

Here is a tutorial I found. Tell me if it sounds accurate:

http://www.tutorialspoint.com/assembly_programming/

How far do I need to go to be able to convert to C-code, or Python if possible. Either would be fine, but I say Python because I know a little Python.

Thanks so much.
ghostheadx2
Contributor
Contributor
 
Posts: 728
Joined: Wed Nov 19, 2014 1:19 am
Blog: View Blog (0)


Re: how to print an assembly value?

Post by ghost107 on Wed May 27, 2015 11:12 am
([msg=88207]see Re: how to print an assembly value?[/msg])

The usual book in assembly that I recommend(AoA - Art of Assembly language, Read DOS 16 Bit Edition, other editions are about HLA - High level Assembly, which is a different programming language).

Also before starting to learn assembly, you must first have to master a high level language(C/C++, C#, Java, Pascal, python, etc), aaembly is a hard to learn language, Even people who know a high level language fail to understand.
http://www.plantation-productions.com/W ... index.html

This is the difference between Intel syntax and AT&T Syntax:
http://www.imada.sdu.dk/Courses/DM18/Li ... elnATT.htm
User avatar
ghost107
Poster
Poster
 
Posts: 321
Joined: Wed Jul 02, 2008 7:57 am
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests