Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More algorithm for rahash2 -E and a dedicated r2 command #4254

Closed
35 of 39 tasks
Maijin opened this issue Mar 7, 2016 · 32 comments
Closed
35 of 39 tasks

More algorithm for rahash2 -E and a dedicated r2 command #4254

Maijin opened this issue Mar 7, 2016 · 32 comments

Comments

@Maijin
Copy link
Contributor

Maijin commented Mar 7, 2016

Hey, I think could be cool to add more useful crypto within r2 especially for malware analysis, here are some common one that can be found in pycrypto. See 3f5aa46 to know where/how to implement them

It needs to be able to do that on file as well and Also a command to do that within r2 could be neat

  • Ability to rehash -E to handle file like rahash2 -S key -E rc4 file.exe
    • Tested
  • Command for crypto in radare2
    • woE
      • Tested
    • woD
      • Tested

More related stuff here to do ! #4280

@radare
Copy link
Collaborator

radare commented Mar 7, 2016

Which command do u like for doing this from r2? Maybe like wo?

On 07 Mar 2016, at 14:16, Maijin [email protected] wrote:

Hey, I think could be cool to add more useful crypto within r2 especially for malware analysis, here are some common one that can be found in pycrypto. See 3f5aa46 to know where/how to implement them

ARC2
ARC4 #4229
Blowfish
XOR (with a string and not with just a byte like in rax2)
CAST
DES
DES3
PKCS1_OAEP
PKCS1_v1_5
Also a command to do that within r2 could be neat

Command for crypto

Reply to this email directly or view it on GitHub.

@radare
Copy link
Collaborator

radare commented Mar 7, 2016

Can you find small and simple c implementations for all those algorithms?

On 07 Mar 2016, at 14:16, Maijin [email protected] wrote:

Hey, I think could be cool to add more useful crypto within r2 especially for malware analysis, here are some common one that can be found in pycrypto. See 3f5aa46 to know where/how to implement them

ARC2
ARC4 #4229
Blowfish
XOR (with a string and not with just a byte like in rax2)
CAST
DES
DES3
PKCS1_OAEP
PKCS1_v1_5
Also a command to do that within r2 could be neat

Command for crypto

Reply to this email directly or view it on GitHub.

@Maijin
Copy link
Contributor Author

Maijin commented Mar 7, 2016

Yeah wo family command would be ok Here is the pycrypto repo with C code https://github.com/dlitz/pycrypto/tree/master/src

@lionaneesh
Copy link
Contributor

I'll work on implementing RC2.

@PankajKataria
Copy link
Contributor

I am working on XOR

@oddcoder
Copy link
Contributor

oddcoder commented Mar 7, 2016

cool guys :+1

@kishorbhat
Copy link
Contributor

This sounds fun! I'd like to work on Blowfish.

Note: as per issues filed there, the pycrypto library is no longer actively maintained (see this). Apparently development and other projects have moved to pycryptodome, which has everything pycrypto has and more.

@PankajKataria
Copy link
Contributor

for XOR encryption what can we do if the input contains null bytes. The rahash2.c will not pass the full string to the encryption plugin like for example :
"rahash2 -S key -E XOR -s hello' world\n' " will give correct output but
"rahash2 -S key -E XOR -s hello' world\n' | rahash2 -S key -E XOR -s - "
will give 'h' as output as because in the output of the encryption there will be a null byte (ie e(xor)e )

@radare
Copy link
Collaborator

radare commented Mar 7, 2016

I would prefer the lowercase name here: xor

On 07 Mar 2016, at 22:08, Pankaj Kataria [email protected] wrote:

for XOR encryption what can we do if the input contains null bytes. The rahash2.c will not pass the full string to the encryption plugin like for example :
"rahash2 -S key -E XOR -s hello' world\n' " will give correct output but
"rahash2 -S key -E XOR -s hello' world\n' | rahash2 -S key -E XOR -s -
will give 'h' as output as because in the output of the encryption there will be a null byte (ie e(xor)e )


Reply to this email directly or view it on GitHub.

@chinmaydd
Copy link
Contributor

I plan to work on implementing DES.

@Maijin
Copy link
Contributor Author

Maijin commented Mar 8, 2016

I have added in the issue:

Ability for rahash2 -E to handle file like rahash2 -S key -E rc4 file.exe for example

@condret
Copy link
Member

condret commented Mar 8, 2016

we allready have DES, but it is broken

@Maijin
Copy link
Contributor Author

Maijin commented Mar 8, 2016

@PankajKataria
Copy link
Contributor

Should we consider the case of only one file provided, If not then please suggest suitable format to separate the output. Currently, I am printing newlines after every encrypted file.

@Maijin
Copy link
Contributor Author

Maijin commented Mar 8, 2016

@PankajKataria What u mean? Like decrypting/encrypting several file like rahash2 -S key -E rc4 file.exe file2.exe and so on?

@PankajKataria
Copy link
Contributor

@Maijin Yup

@Maijin Maijin changed the title More algorithm for rehash -E and a dedicated r2 command More algorithm for rahash2 -E and a dedicated r2 command Mar 9, 2016
@Maijin Maijin added the rahash2 label Mar 9, 2016
@Maijin
Copy link
Contributor Author

Maijin commented Mar 14, 2016

AES is not done/not working in fact feel free to do add support for that as well :)

@l4l
Copy link
Contributor

l4l commented Mar 18, 2016

I'm going to fix aes algo

@radare
Copy link
Collaborator

radare commented Mar 21, 2016

Cool!

Maybe @condret can point you to the issues he was having and the eay to integrated in esil. But for now just focus on implementing it for rahash2

Thanks

On 18 Mar 2016, at 22:47, Evgeny [email protected] wrote:

I'm going to fix aes algo


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@l4l
Copy link
Contributor

l4l commented Mar 22, 2016

I've done with most of the work for implementation here but there is still critical bug(s) that I still cannot find. So I really will be glad to receive any help with it

@radare
Copy link
Collaborator

radare commented Mar 22, 2016

can you describe the bug? :P

On 22 Mar 2016, at 19:50, Evgeny [email protected] wrote:

I've done most of the work for implementation here l4l@e27f953 but there is still critical bug(s) that I still cannot find. So I really will be glad to receive any help with it


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #4254 (comment)

@l4l
Copy link
Contributor

l4l commented Mar 22, 2016

Some buffer overflow. Logs: gdb, asan
Command like ``rahash2 -E aes-ecb -S 32*'1' -s 256*'A'`

@radare
Copy link
Collaborator

radare commented Mar 22, 2016

use valgrind, this is a clear buffer overflow at radare2/libr/crypto/crypto.c:120

On 22 Mar 2016, at 20:35, Evgeny [email protected] wrote:

Some wierd buffer overflow. Logs: gdb http://pastebin.com/sHj9YBKC, asan http://pastebin.com/7gifQDc6

You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #4254 (comment)

@ninjahacker
Copy link
Contributor

Modes should be written separately from the cipher algorithms so they can be reused easily. CBC is CBC is CBC. It doesn't matter whether it is AES-CBC or Blowfish-CBC. This way as new things get added, you automatically have all the modes for it. It's also just bad to write the same code 100x. You should be able to do something like (obviously with better naming and thinking of the arguments):

do_cbc_encrypt(aes, iv, input, output, length)
do_cbc_decrypt(blowfish, iv, input, output, length)

etc...

@Maijin
Copy link
Contributor Author

Maijin commented Apr 9, 2016

Feel free to change the stuff :P But having all of those basics would be already cool prior doing fancy stuff...

@ninjahacker
Copy link
Contributor

I haven't looked at the code to see how it was structured yet, but I just wanted to make a note of it since I see CBC listed. It's going to be harder to change later if you don't plan ahead for it. Especially if people start wanting ofb, cfb, xts, and whatever popular thing will spring up next month. And malware authors like to be all trendy and use the fancy new modes, right?

@Maijin
Copy link
Contributor Author

Maijin commented Apr 9, 2016

RAT still used rot13, arc4, xor, aes-cbc a lot so definitely not fancy.

@ninjahacker
Copy link
Contributor

I was trying to be funny... :(

@Maijin
Copy link
Contributor Author

Maijin commented Jun 28, 2016

:?

@radare
Copy link
Collaborator

radare commented Jun 29, 2016

ping

@radare radare modified the milestones: 0.10.5, 0.10.4 Jun 29, 2016
@radare radare modified the milestones: 0.10.6, 0.10.5 Aug 8, 2016
@radare radare modified the milestones: 9999, 0.10.6 Sep 19, 2016
@wargio
Copy link
Contributor

wargio commented Mar 1, 2017

there is no 3DES yet.

@Maijin
Copy link
Contributor Author

Maijin commented Mar 8, 2017

See hxxps://github.com/radare/radare2/issues/6946

@Maijin Maijin closed this as completed Mar 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests