title: How can Python 2's input() be exploited cause a comparison against a random number yet-to-be-generated to pass?
body: <p>I understand that relying on Python 2's built-in <code>input()</code> function (as opposed to <code>raw_input()</code>, which was renamed to <code>input()</code> in Python 3) is prone to security bugs. In this question, I'm trying to determine how to demonstrate this class of vulnerability.</p>
  
  <hr>
  
  <p>Specifically, I'm trying to determine how to generate input to the code below which will cause "Access granted" to be emitted, <strong>without modifying the program itself</strong>, only by changing the value passed to stdin in response to the <code>input()</code> call.</p>
  
  <pre><code>import random
  pass_true = input("What is the password?")
  password = random.randint(0,2**30)
  
  if password == pass_true:
      print("Access granted.")
  else: 
      print ("Access denied.")
  </code></pre>
  
  <p>If the random number were generated <em>before</em> the input call (that is, if the second and third lines were switched), one could merely enter <code>pass_true</code> as the string, which would subsequently be evaluated to the value of the variable by that name -- but since the random number isn't yet known at the <code>input()</code> invocation, this approach doesn't work.</p>