title: Brute Force numeric attack on any file
body: <p>I wrote this brute force attacker in Python. It cracks any file numeric password protected file.</p>
  <pre><code>import pikepdf
  
  def brute_num_attack(file):
      i = 0
      while True:
          try:
              print(i)
              with pikepdf.open(file, password=str(i)) as file:
                  print(&quot;Password: &quot;, i)
                  print(&quot;Total pages:&quot;, len(file.pages))
                  break
          except:
              i += 1
  </code></pre>
  <p>If I need this to do a brute force attack of all alphanumeric characters and punctuation, how should I do it?</p>
  <p>Using this:</p>
  <pre><code>characters = string.ascii_letters + string.digits + string.punctuation
  </code></pre>
  <p>This is just for proof of concept how brute force is implemented.</p>