You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on some new sample, I was writing a script for decoding embed strings. It has some getting pointers, reading encrypted string, string deciphering and adding a comment to the place, where the string is. Script is looked as the following:
r2=r2pipe.open(r'path-to-a-binary')
ea=0x14002a1f0end_ea=0x14002ae10whileea<end_ea:
va=r2.cmdj('pxqj 8 @ 0x%x'%ea) # read qword of string pointerifnotva:
breakva=va[0]
s=r2.cmd('px0 @ 0x%x'%va) # should be optimized, in case there is 2GB string :)ifnots:
breaks=bytes.fromhex(s) +b'==='ifnots:
print('- cannot get str at %08x'%ea)
breaktry:
print('trying to decrypt: %08x'%va)
decr=decrypt_str(s)
print('%08x: "%r"'% (va, decr.decode('utf8')))
r2.cmd('CCa 0x%x "%s"'% (va, decr.decode('utf8'))) # <<< problem commandexcept:
print('cannot decode string at %08x "%s": %s'% (va, s, traceback.format_exc()))
ea+=8
While running this script I got the assertion failure:
That was strange, because a stack trace showed that this code is inside rading from console:
Digging deeper into this, I realized that some of the comments which was passed to CCa command had have \n inside. So, that means a comment string was splitted by radare by \n and interpreted as a separate command. The following code finfirmed my thoughts:
the string after \n is lol and was interpreted by radare2 as list files and directories command.
This means if user automatically decrypts some string and wanted to store it as a comment, he can occasionnaly run some valid radare2 command and pwn itself. For example he can write some shellcode and execute it or spawn some shell command.
The text was updated successfully, but these errors were encountered:
Environment
Story
While working on some new sample, I was writing a script for decoding embed strings. It has some getting pointers, reading encrypted string, string deciphering and adding a comment to the place, where the string is. Script is looked as the following:
While running this script I got the assertion failure:
That was strange, because a stack trace showed that this code is inside rading from console:
Digging deeper into this, I realized that some of the comments which was passed to
CCa
command had have\n
inside. So, that means a comment string was splitted by radare by\n
and interpreted as a separate command. The following code finfirmed my thoughts:the string after
\n
islol
and was interpreted by radare2 aslist files and directories
command.This means if user automatically decrypts some string and wanted to store it as a comment, he can occasionnaly run some valid radare2 command and pwn itself. For example he can write some shellcode and execute it or spawn some shell command.
The text was updated successfully, but these errors were encountered: