S
S
sazer2019-06-02 22:09:58
Python
sazer, 2019-06-02 22:09:58

Need help with running python file with gdb. Can anyone help?

I just can't run the .py file whose code is below. At startup, it gives out that it cannot find gdb, and at startup, another error occurs from gdb. I've been fighting for 2 days, nothing happens, I don't know how to solve the problem.
Can someone tell me how to get everything up and running?
Thanks a lot.

#!gdb
import sys
import gdb
import os
os.system("echo resetFile > eip.txt")
number_restarts = 100
gdb.execute("set pagination off")
os.system("/usr/share/metasploit-framework/vendor/bundle/ruby/2.3.0/gems/rex-bin_tools-0.1.4/bin/msfelfscan -j esp ./crossfire > jmpSearch.txt")
def on_stop(sig):
  global number_restarts
  if isinstance(sig, gdb.SignalEvent):
    if (number_restarts > 0):
      os.system("rm eip.txt")
      gdb.execute("set confirm off")
      gdb.execute("set logging file eip.txt")
      gdb.execute("set logging on")
      gdb.execute("set logging overwrite on")
      gdb.execute("info registers eip")
      gdb.execute("set logging off")
      gdb.execute("set logging file badchars.txt")
      gdb.execute("set logging on")
      gdb.execute("x/500xw $esp")
      gdb.execute("set logging overwrite off")
      gdb.execute("set logging off")
      gdb.execute("kill")
      gdb.execute("run")
gdb.events.stop.connect (on_stop)
gdb.execute("run")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2019-06-02
@sergey-gornostaev

You can import the gdb module only when the script is running in gdb.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question