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

Adding wo*y commands using clipboard instead of [val] #4533

Closed
wants to merge 2 commits into from

Conversation

cr
Copy link
Contributor

@cr cr commented Apr 5, 2016

When working with streaming ciphers, being able to XOR memory regions inside radare is super nifty. This implementation uses the clipboard as XOR key which is repeated when it is shorter than blocksize.

@radare
Copy link
Collaborator

radare commented Apr 5, 2016

You can already do this with the wox command. not in the clipboard.. and there are several other "encryption" algorithms and checksums that can be applied to a buffer, so i would prefer not to have more dupplicated commands, unless we follow the same schema.

For example. having yo subcommands to mimic the wo ones. and share as much code as possible between them.

@cr
Copy link
Contributor Author

cr commented Apr 5, 2016

You can already do this with the wox command.

wox makes you specify the key on the command line which is not feasible with a 1K stream cipher. The main motivation for yX was to be able to XOR two memory regions.

My first instinct was to extend the wox command accordingly, but you end up introducing one or two awkward length parameters. Using the clipboard instead makes it elegant to simply yank a key from somewhere, then XOR it where needed.

@radare
Copy link
Collaborator

radare commented Apr 5, 2016

oh i get your point. Using the clipboard as a place to store the key. My suggestion would be to add an y suffix to the wo. commands and take the clipboard as key instead of parsing the argument.

> woxy

@cr cr force-pushed the cr-xor branch 2 times, most recently from d43a6ac to e1e10f2 Compare April 5, 2016 23:25
@cr cr changed the title Adding yX command for clipboard XOR to block Adding wo*y commands using clipboard instead of [val] Apr 5, 2016
@cr
Copy link
Contributor Author

cr commented Apr 5, 2016

An elegant patch just turned ugly, but I may have made it. make tests runs without errors, but if the integration test here fails again, I don't know what's causing it, because it seems I can't read its output here.

@cr cr force-pushed the cr-xor branch 2 times, most recently from 65e2582 to 4a696f3 Compare April 5, 2016 23:32
@cr
Copy link
Contributor Author

cr commented Apr 5, 2016

I couldn't bring myself to rewrite the arg parsing for the woE command.

@cr
Copy link
Contributor Author

cr commented Apr 5, 2016

I am getting second thoughts here: Wouldn't it be more sensible to fall back to clipboard when no [val] is given instead of introducing the wo*y class of commands?

@cr
Copy link
Contributor Author

cr commented Apr 6, 2016

I have a version ready that falls back to clipboard when no [val] is given. Let me know if you prefer that, and I'll push it here first thing in the morning.

@Maijin
Copy link
Contributor

Maijin commented Apr 6, 2016

Hey dat looks cool stuff, have you checked #4280 and #4254 as it is a bit related?

"wor"," [val]", ">>= shift right",
"wol"," [val]","<<= shift left",
"wo2"," [val]","2= 2 byte endian swap",
"wo4"," [val]", "4= 4 byte endian swap",
"wo*y", "", "same as their counterparts above, but using clipboard instead of [val]",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shuold be alphabetically sorted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a mess before, so it was hard to make out the right spot. I tried to work surgically. Shouldn't a cleanup here be part of a different pull request?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r2 have a huge codebase and we try to have as much testcases as possible in order to not break stuff, because one of the main premises is the continuous refactoring, mainly because most of the stuff that is implemented in r2 is done "quickly" because is a feature someone needs for something NOW. but there are always better ways to do stuff, so that's where the refactoring enters the game. you can do this alphabetically sorting thing in the same PR, there's no real issue in sorting out a text array that will be processed by humans.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation. I'm sorry. I didn't mean to drive you into defense. :/

I will push along a separate commit in this pull request.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Into defense? Dont take me wrong. Im not trying to be offensive or anything. Just trying to give some feedback on every new contributor just to discuss better way to handle this.

Thats a very nice addition :) take a beer and chill a bit ;)

Ill merge after lunch

Thx

On 07 Apr 2016, at 14:49, Christiane Ruetten [email protected] wrote:

In libr/core/cmd_write.c:

    "wor"," [val]", ">>= shift right",
    "wol"," [val]","<<= shift left",
    "wo2"," [val]","2=  2 byte endian swap",
    "wo4"," [val]", "4=  4 byte endian swap",
  •   "wo*y", "", "same as their counterparts above, but using clipboard instead of [val]",
    
    Thanks for the explanation. I'm sorry. I didn't mean to drive you into defense. :/

I will push along a separate commit in this pull request.


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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No offense taken at all! I was just slightly worried that you felt offended because you started justifying radare code quality there.

@radare
Copy link
Collaborator

radare commented Apr 7, 2016

Sorry for the late reply, its been a crazy day yesterday. Can you address the comments and update the PR? looks good to merge

@radare radare added this to the 0.10.2 milestone Apr 7, 2016
@cr
Copy link
Contributor Author

cr commented Apr 7, 2016

@radare, please comment on #4533 (comment) . I much prefer that solution.

@cr
Copy link
Contributor Author

cr commented Apr 7, 2016

TBH, I have never gotten in that much trouble for not touching the existing code. I am thankful that you pointed out the mistakes I was about to leave in place, but I also feel that we might be better off to separate my feature work from what seems to be a much-needed audit/rewrite of the existing code.

Christiane Ruetten added 2 commits April 7, 2016 14:54
When the [val] argument to wo* subcommands is omitted, clipboard
content is used instead. This allows, for example, to easily XOR
two memory blocks.
@cr
Copy link
Contributor Author

cr commented Apr 7, 2016

Woah, someone merged this PR into master before we were done with the review. :(

@cr
Copy link
Contributor Author

cr commented Apr 7, 2016

I am closing this PR. There's not much sense in trying to fix the broken merge on top of this.

@radare
Copy link
Collaborator

radare commented Apr 7, 2016

wtf?

you dont have to fix any merge and you can push -f in pr'd branches perfectly. github handles this

@radare radare reopened this Apr 7, 2016
@radare
Copy link
Collaborator

radare commented Apr 7, 2016

ok moved to #4548

@radare radare closed this Apr 7, 2016
@cr
Copy link
Contributor Author

cr commented Apr 7, 2016

This PR was poisoned because I had force-pushed into this branch without realizing that it had already been merged.

@cr cr deleted the cr-xor branch April 7, 2016 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants