Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have some interest if finding out a bit more about an exploit that was published that creates a root user in a linux machine; however, before I run the code, I want to make sure I understand all of it and I can't seem to find any information on the hex codes being used.

This is the link to the exploit code source: exploitdb.com/exploits/17439

It's a basic C program, but the value of one of the pointers uses code like this:

           "\x6a\x26\x5a\x25\x04\xe3\xb3\x64"
           "\x04\xc7\x03\x65\x48\xe6\x02\xc3"

How do I decode this to ASCII and how can I re-encode it back?

I'm thinking I could be totally off-base here and really this code should decode to assembly, but I don't really know. Either way, what can I do with this code to make sure I'n not executing arbitrary commands?

I'm completely new to C, but know enough VB.net/C#/PHP to be dangerous.

P.S. For those of you who are concerned, I'll be running this in a VM.

share|improve this question

4 Answers 4

up vote 1 down vote accepted

Python's REPL is good in a pinch for stuff like this.

>>> "\x6a\x26\x5a\x25\x04\xe3\xb3\x64"
'j&Z%\x04\xe3\xb3d'
>>> "\x04\xc7\x03\x65\x48\xe6\x02\xc3"
'\x04\xc7\x03eH\xe6\x02\xc3'

So yeah, pretty much all assembly. You'll need a disassembler (or a CPU databook and a lot of patience) in order to read it.

share|improve this answer
    
This is probably getting in to stack overflow territory, but could you provide a basic code example (even if pseudo-code) of how to get python to parse this? –  skub Jul 8 '11 at 5:50
    
There is no further parsing. What I showed is what Python knows about it. You will need a disassembler (or a ...) from here. –  Ignacio Vazquez-Abrams Jul 8 '11 at 5:52
    
Maybe you want to ask this on codegolf.stackexchange.com perhaps they can help you. –  Michael K Jul 8 '11 at 7:26

I made a php array of these, i'm not sure if it will help but it'll show you the conversion, remove the zeros though for your applicable needs.

$constarray = array( "0x20" => " ", "0x21" => "!", "0x22" => '"', "0x23" => "#", "0x24" => "$", "0x25" => "%", "0x26" => "&", "0x27" => '"', "0x28" => "(", "0x29" => ")", "0x2a" => "*", "0x2b" => "+", "0x2c" => ",", "0x2d" => "-", "0x2e" => ".", "0x2f" => "/", "0x30" => "0", "0x31" => "1", "0x32" => "2", "0x33" => "3", "0x34" => "4", "0x35" => "5", "0x36" => "6", "0x37" => "7", "0x38" => "8", "0x39" => "9", "0x40" => "@", "0x41" => "A", "0x42" => "B", "0x43" => "C", "0x44" => "D", "0x45" => "E", "0x46" => "F", "0x47" => "G", "0x48" => "H", "0x49" => "I", "0x4a" => "J", "0x4b" => "K", "0x4c" => "L", "0x4d" => "M", "0x4e" => "N", "0x4f" => "O", "0x50" => "P", "0x51" => "Q", "0x52" => "R", "0x53" => "S", "0x54" => "T", "0x55" => "U", "0x56" => "V", "0x57" => "W", "0x58" => "X", "0x59" => "Y", "0x5a" => "Z", "0x5b" => "[", "0x5c" => "\", "0x5d" => "]", "0x5e" => "^", "0x5f" => "_", "0x60" => "`", "0x61" => "a", "0x62" => "b", "0x63" => "c", "0x64" => "d", "0x65" => "e", "0x66" => "f", "0x67" => "g", "0x68" => "h", "0x69" => "i", "0x6a" => "j", "0x6b" => "k", "0x6c" => "l", "0x6d" => "m", "0x6e" => "n", "0x6f" => "o", "0x70" => "p", "0x71" => "q", "0x72" => "r", "0x73" => "s", "0x74" => "t", "0x75" => "u", "0x76" => "v", "0x77" => "w", "0x78" => "x", "0x79" => "y", "0x7a" => "z", "0x7b" => "{", "0x7c" => "|", "0x7d" => "}", "0x7e" => "~");

share|improve this answer

Decoding it to ASCII would be useless as it is not a text string - the \x0... bytes map to control characters in the ASCII character set, not to printable characters.

share|improve this answer

The very database entry that you pointed to gives both the original assembly language program, and its C language equivalents, immediately above the hex-encoded raw machine code. It's SuperH assembly language.

share|improve this answer
    
Yes, I know; the comments that contain the assembly may or may not necessarily be the code that in the pointer. I was requesting a way (method or process) to check the code to ensure it is indeed the assembly noted above. And also a method to encode to the appropriate hex code values (which no one answered). –  skub Jul 8 '11 at 12:52
    
That's not in your question as asked, which didn't say anything at all about verification of machine code against assembly language, but did ask about converting to ASCII characters, which is why people's answers talk about that. You didn't ask anything like what you are asking now. And the method to encode assembly language to machine code is known as an assembler. –  JdeBP Jul 8 '11 at 14:27
    
>Either way, what can I do with this code to make sure I'n not executing arbitrary commands? –  skub Jul 9 '11 at 2:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.