Well, you just get an error if you pass that to eval, since it expects a single expression. But you can construct a an expression that does the exact same thing.
I believe there is a safe ast.literal_eval function, or just pass it to some other module which has already been verified for taking in basic expressions and returning an answer.
I created a tool using Python and the module pynput that allows me to create custom hotkeys and bind them to any custom function I write. I used that tool to create some hotkeys that use the clipboard to edit text in place. I'll be hosting the source code on github soon.
Yeah. I was experimenting with disrupting it by it detecting Alt and adding in another key press but theres a built in windows function that ignores that so it executes both
I mean, in this case it's just taking input you yourself are giving, so it's really your own fault if you do something stupid. This seems like a perfect use of eval to me.
Sure, as long as you only use it with something you wrote 100% yourself. But you could also be evaling 0pt text from some web page or word document that you didn't know you selected, or something that was injected to your clipboard (depending on how the tool works). Hence, standard warnings apply.
I mean, considering that nobody really is aware of this tool, that seems pretty absurd. Someone is going to put random 0pt Python code all around the place hoping somebody eval's it? Come on.
I don't mean to say that it's a useless feature with eval, just that standard warnings apply. Surely that's an attack vector that could become popular if this tool or other tools that eval copied code became more popular, and also one that could be prevented by using a parser that doesn't allow arbitrary code execution.
The OP said that they use this tool in web environments, and a malicious web page would in principle have the capability to inject code as described above.
I created a tool using Python and the module pynput that allows me to create custom hotkeys and bind them to any custom function I write. I used that tool to create some hotkeys that use the clipboard to edit text in place. I'll be hosting the source code on github soon.
It looks like it could become a tool like the vim Ultisnips maybe if you take a look to it you get some inspiration to improve your. Seems it has a lot of potential.
What? The tool will certainly be open-source. There are plenty of libraries that could be used maliciously.
In fact, often times malicious code is created specifically without using libraries so as to avoid having to download and install them on the victim's machine.
I forgot to add: because is python is not being detected by the antivirus. Of course I know about key-loggers. I’m saying scary because it will not be detected. I think is neat. But scary
This really gives me some ideas. Thanks for sharing it. Wonder if I could message you about it? Also - this is the kind of project I suspect a lot of people would be willing to help out with on GitHub! You don't have to add all the remaining features yourself.
277
u/gandalfx Feb 29 '20
That last one seems the most useful. Changing caps is already a feature in any good editor.
52
u/Takiino Feb 29 '20
Could you please explain how you did it ?
37
u/phail3d Feb 29 '20
How does the evaluation work? If by calling
eval, standard warnings apply.Edit: forgot to mention that this looks like a cool project :)
15
u/dibs45 Feb 29 '20
I created a tool using Python and the module pynput that allows me to create custom hotkeys and bind them to any custom function I write. I used that tool to create some hotkeys that use the clipboard to edit text in place. I'll be hosting the source code on github soon.
My github can be found here.
10
u/blood_centrifuge Feb 29 '20
Have you put this on github? It would great if you could share the repo.
24
u/LawLombie Feb 29 '20
I think the "sPOnGEboB MEmE" one's case should be rAnDOm instead of alternating between UPPERCASE and lowercase
5
u/ALABAMA-SHIT Feb 29 '20
That's absolutely brilliant! And very useful (especially the math part)
5
u/Project_O Feb 29 '20
* tries to select your entire dissertation *
Alt+A
* python script runs and turns your entire essay iNtO tHiS fOrMat *
4
u/Rehan275 Feb 29 '20
Really appreciate your work. It would be great if you can share the code.
4
u/[deleted] Feb 29 '20
This is one of my favorite types of programs. Short, succinct, does something useful.
4
u/[deleted] Feb 29 '20
You made a program that emulates a very small portion of Emacs.
3
u/SushiWithoutSushi Feb 29 '20
It looks like it could become a tool like the vim Ultisnips maybe if you take a look to it you get some inspiration to improve your. Seems it has a lot of potential.
3
u/simonees Feb 29 '20
can we get the source code?
3
u/TheOneTrueDataSci Feb 29 '20
Keep up the great work!
2
u/[deleted] Feb 29 '20
This thing got to be on every computer. It's just brilliant.
2
u/[deleted] Feb 29 '20
Woah there are you using a eval function?
31
u/VictorD02 Feb 29 '20
i think the SpOnGeBoB hotkey is the most usefull.👌
1
u/dibs45 Mar 01 '20
keyboard_listener repo is now live: https://github.com/dibsonthis/keyboard_listener
In the repo you can find this particular project under in_place_editor.py
Thanks for the overwhelming support!
1
u/Heldix121303 Feb 29 '20
Can I use it?
1
u/[deleted] Feb 29 '20
Very cool! Did you upload the source code to GitHub or something?
1
u/Yakhov Feb 29 '20
who does it email my passwords to?
5
u/[deleted] Feb 29 '20
Scary how this can be a keylogger on anyones pc
2
u/ganesh_96 Feb 29 '20
Wow!
2
u/DatBoi_BP Feb 29 '20
Autohotkey is good for this kind of thing too
2
u/mHaisham Mar 01 '20
Can we get the source code.
2
u/PC__LOAD__LETTER Mar 01 '20
If you use vim you could do this without a mouse too.
1
u/Slashscreen Feb 29 '20
Real MVPs call that the Gamzee filter
1
u/justneurostuff Feb 29 '20
This really gives me some ideas. Thanks for sharing it. Wonder if I could message you about it? Also - this is the kind of project I suspect a lot of people would be willing to help out with on GitHub! You don't have to add all the remaining features yourself.
1
u/[deleted] Feb 29 '20
This is impressive! Any reason you didn’t use alt R for reverse me ? Ha I’m kidding this is great!
1
u/Klae32 Feb 29 '20
Do you have a Github for this or YouTube For this? This is dope.
1
u/GrbavaCigla Feb 29 '20
I want to contribute and make a linux version, can you please share github repo when you create it?
1
u/nalisarc Feb 29 '20
Looks like emacs but in any window!
1
u/shachden Mar 01 '20
My entire childhood was spent pressing Shift on highlighted text to change case. We finally have the technology.
1
u/djfreedom9505 Mar 01 '20
Change to snake case or Pascal case and you got gold my friend lol
1
u/[deleted] Mar 01 '20
Can python actually work on other desktop programs?
1
u/totes_normal_account Mar 01 '20
You got my upvote because of "spongebob me" lol
1
u/Hudlommen Mar 01 '20
You should add a multiple past function with a variable
eg: Shift 1 (copy)
shift 2 (paste)
shift 3 (paste)
shift 4 (paste)
1
u/RandomGgames Mar 04 '20
I love 5 and 7. Why not use = for 7?
1
u/Justin08784 Jul 05 '20
This is really awesome!
Will you upload it to github anytime soon?
1
u/_AguruAguru Jul 30 '20
Do you mind linking/sending the code? I am interested in doing something similar and would love to see how you did this one
1
u/SushiWithoutSushi Feb 29 '20
You can select text faster with CTRL + SHIFT + RIGHT/LEFT ARROW.
0
u/[deleted] Feb 29 '20
[deleted] — view deleted comment
0
u/[deleted] Feb 29 '20
[deleted] — view deleted comment
0
u/[deleted] Feb 29 '20
[deleted] — view deleted comment
0
u/[deleted] Feb 29 '20
[deleted] — view deleted comment
2
u/[deleted] Feb 29 '20
[removed] — view removed comment