It's simple: To get past your check, just type password at the prompt :-) Try it!

What is the password?password
Access granted.

Explanation: input reads what you type, evaluates it as python code, and assigns the result to pass_true. So in the above, I just told it to assign the value of the variable password (which holds the real password) to pass_true.

But this code is broken even for regular use: If you type anything that doesn't look like a valid python expression, it'll trigger an error. Your example uses numbers as "passwords", but you couldn't use the same approach for arbitrary-text passwords: It wouldn't work at all, even with the correct password.

Another kind of problem is typing something damaging like os.remove(".profile") (or something worse and more elaborate) at the prompt. It won't log them in but you can see the damage it can do. Evaluating user input is just wrong, unless you're writing an interactive python interpreter.

Python 2 has raw_input() which just reads input. (In python 3, raw_input() has been renamed to input() and the old input() is gone).

Answer from alexis on Stack Overflow
🌐
Medium
medium.com › swlh › hacking-python-applications-5d4cd541b3f1
Hacking Python Applications. And how attackers exploit common… | by Vickie Li | The Startup | Medium
November 15, 2019 - Dangerous functions in Python like eval(), exec() and input() can be used to achieve authentication bypass and even code injection.
Discussions

Demo of how input() is security probem in Python 2.7 (4min)
Demo of how writing insecure code is a security problem. More on reddit.com
🌐 r/Python
60
84
March 14, 2018
Python Search – eval(raw_input())
Github is turning up these results because that bit of Python is inside the C code as a string documenting the function · Python 3 does not evaluate what's passed to input(), however. To get the same effect, use eval(input()). [1] More on news.ycombinator.com
🌐 news.ycombinator.com
19
17
April 29, 2014
🌐
Null Byte
null-byte.wonderhowto.com › how-to › train-your-python-part-4-basic-user-input-0165208
How to Train Your Python: Part 4, Basic User Input :: Null Byte
October 10, 2015 - To start, we'll just be using the function without anything extra, just to get a feel for it. So, let's enter "raw_input" into our python interpreter...
🌐
Blogger
intx0x80.blogspot.com › 2017 › 05 › python-input-vulnerability_25.html
python input vulnerability
May 25, 2017 - and if we enter number it will display it but what if we enter 2+4 it will display 6 because it's use eval as part of input function as we see above from here we can use __builtin__ module to get
🌐
Reddit
reddit.com › r/python › demo of how input() is security probem in python 2.7 (4min)
r/Python on Reddit: Demo of how input() is security probem in Python 2.7 (4min)
March 14, 2018 - I see people do shit like make a django site that invokes a python script that invokes a bash shell script that invokes a php script, and I'm not even fucking joking. Life finds a way. ... Well if people didn't do string interpolations with user input and run them in a shell I'd be out of a job. But, yeah, don't do that. ... Yeah it seems like you'd have to put in some effort to use it in an insecure way that's not just "hacking" yourself.
🌐
Vickieli
vickieli.dev › hacking › hack-python
Hacking Python Applications - Vickie Li’s Security Blog
September 14, 2020 - Dangerous functions in Python like eval(), exec() and input() can be used to achieve authentication bypass and even code injection.
Find elsewhere
🌐
Null Byte
null-byte.wonderhowto.com › news › learn-code-python-part-one-variables-input-and-output-0133579
Learn to Code in Python, Part One: Variables, Input and Output :: Null Byte
February 27, 2012 - Here's an example of a simple program that adds two integers together using the input() function: ... Note: Notice how I use a comma (,) in place of an addition symbol (+) when "adding" integers into strings. Stay tuned for part two, which will cover more on strings, as well as an introduction to definitions. ... Apple's iOS 26 and iPadOS 26 updates are packed with new features, and you can try them before almost everyone else. First, check Gadget Hacks' list of supported iPhone and iPad models, then follow the step-by-step guide to install the iOS/iPadOS 26 beta — no paid developer account required.
🌐
GeeksforGeeks
geeksforgeeks.org › python › amazing-hacks-python
Amazing hacks of Python - GeeksforGeeks
September 13, 2023 - # Reads a string from input and type case them to int # after splitting to white-spaces formatted_list = list(map(int, input().split())) print(formatted_list)
🌐
Sololearn
sololearn.com › en › Discuss › 1338250 › assignment-hack-sls-python-input
[Assignment] Hack SL's Python input() | Sololearn: Learn to code for FREE!
Here is the idea : Before this ... codeplayground with Python. It appeared to be actually possible, using fileinput module, or as well using while + yield....
🌐
VICE
vice.com › home › hack this: scripting deeper, better hacks in python
Hack This: Scripting Deeper, Better Hacks in Python
July 28, 2024 - You should take a few minutes to the look at the Learn Python the Hard Way section on variables and names, and also the section on strings and text. Let’s try something a little different. Open up your hello.py script and change it to the following: print “Hello What?”, some_input = raw_input() print “Hello, %s” % some_input
🌐
GeeksforGeeks
geeksforgeeks.org › ethical-hacking-with-python
Ethical Hacking with Python | GeeksforGeeks
July 7, 2021 - Note: To know more about python click here. Everyone knows that passwords are not stored a plain text in the website's database. Now we are going to see how to hack a plain text password when you find a password that is in hashed(md5) format. So we take the input_hash(hashed password in the database) and try to compare it with md5 hash of every plain text password which is in a password file(pass_doc) and when the hashes are matched we simply display the plain text password which is in the password file(pass_doc).
🌐
Medium
devdotpy.medium.com › python-for-ethical-hacking-858736acf3cc
Python For Ethical Hacking. Python is a very easy and powerful… | by moo | Medium
February 5, 2021 - Now that we understood how this process works let’s implement this above algorithm using python · import hashlib #a built in module containing many encryption algorithms my_hash = input("Enter the hash you want to crack: ") words = input("Words list file location: ") for word in words: new_hash = hashlib.shae256(word.strip().encode('ascii')) if new_hash == my_hash: print(f"Password found: {word}") break print("The password was not found in this file :( ")
🌐
GitHub
github.com › topics › python-hacking
python-hacking · GitHub Topics · GitHub
go automation social-media osint email hacking pwn pentest information-gathering email-checker data-breach python-hacking socmint osint-tool verification-service ... Get Keyboard,Mouse,ScreenShot,Microphone Inputs from Target Computer and Send to your Mail.
🌐
GitHub
gist.github.com › battis › 5400609
IPython Notebook Input Hack · GitHub
IPython Notebook Input Hack. GitHub Gist: instantly share code, notes, and snippets.
🌐
GitConnected
levelup.gitconnected.com › 30-python-hacks-every-developer-should-know-11d4b5f95be5
30 Python Hacks Every Developer Should Know | by Abhay Parashar | Level Up Coding
November 11, 2021 - It is a versatile language that can be used to create almost everything in the software industry. One of the biggest advantages of python is its one-liners and packages that can do any task with few lines of code. Having so many built-in functionalities, there are some hacks that you should remember while coding in python.
🌐
Hacker News
news.ycombinator.com › item
Python Search – eval(raw_input()) | Hacker News
April 29, 2014 - Github is turning up these results because that bit of Python is inside the C code as a string documenting the function · Python 3 does not evaluate what's passed to input(), however. To get the same effect, use eval(input()). [1]
🌐
Infosec Institute
resources.infosecinstitute.com › topic › writing-hacking-tools-with-python-part-1
Master Python for Ethical Hacking: Part One | Infosec
December 22, 2020 - There is a library called sys which enables you to interact with the system itself. On the least part of its use, we will receive input from the user by parameters. You can also employ the optparse library, which solves this purpose and comes up with a cool help menu too.
🌐
HackerRank
hackerrank.com › challenges › python-raw-input › tutorial
Reading Raw Input | HackerRank
When a line of input is entered, that string of text is saved to the variable. Similarly, you can read a line of input from stdin without passing any string arguments to raw_input or input.