From 2dae43f0ce44fdde80c17b41c35a7def1212e78b Mon Sep 17 00:00:00 2001 From: Long Le Date: Sat, 30 Apr 2016 17:42:05 +0700 Subject: [PATCH 01/25] - Update getpid() and get_vmmap() to make it works on OSX --- peda.py | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/peda.py b/peda.py index e087f90..dc6f123 100644 --- a/peda.py +++ b/peda.py @@ -442,17 +442,8 @@ def getpid(self): else: return None - if self.getos() == "Linux": - out = self.execute_redirect('info proc') - - if out is None: # non-Linux or cannot access /proc, fallback - out = self.execute_redirect('info program') - out = out.splitlines()[0] - if "process" in out or "Thread" in out: - pid = out.split()[-1].strip(".)") - return int(pid) - else: - return None + pid = gdb.selected_inferior().pid + return int(pid) if pid else None def getos(self): """ @@ -1450,6 +1441,30 @@ def _get_offline_maps(): return binmap + def _get_allmaps_osx(pid, remote=False): + maps = [] + #_DATA 00007fff77975000-00007fff77976000 [ 4K] rw-/rw- SM=COW /usr/lib/system/libremovefile.dylib + pattern = re.compile("([^\n]*)\s* ([0-9a-f][^-\s]*)-([^\s]*) \[.*\]\s([^/]*).* (.*)") + + if remote: # remote target, not yet supported + return maps + else: # local target + try: out = execute_external_command("vmmap -w %s" % self.getpid()) + except: error_msg("could not read vmmap of process") + + matches = pattern.findall(out) + if matches: + for (name, start, end, perm, mapname) in matches: + if name.startswith("Stack"): + mapname = "[stack]" + start = to_int("0x%s" % start) + end = to_int("0x%s" % end) + if mapname == "": + mapname = name.strip() + maps += [(start, end, perm, mapname)] + return maps + + def _get_allmaps_freebsd(pid, remote=False): maps = [] mpath = "/proc/%s/map" % pid @@ -1505,7 +1520,10 @@ def _get_allmaps_linux(pid, remote=False): result = [] pid = self.getpid() if not pid: # not running, try to use elfheader() - return _get_offline_maps() + try: + return _get_offline_maps() + except: + return [] # retrieve all maps os = self.getos() @@ -1513,7 +1531,8 @@ def _get_allmaps_linux(pid, remote=False): maps = [] try: if os == "FreeBSD": maps = _get_allmaps_freebsd(pid, rmt) - elif os == "Linux" : maps = _get_allmaps_linux(pid, rmt) + elif os == "Linux" : maps = _get_allmaps_linux(pid, rmt) + elif os == "Darwin" : maps = _get_allmaps_osx(pid, rmt) except Exception as e: if config.Option.get("debug") == "on": msg("Exception: %s" %e) @@ -1632,7 +1651,10 @@ def get_disasm(self, address, count=1): - asm code (String) """ code = self.execute_redirect("x/%di 0x%x" % (count, address)) - return code.rstrip() + if code: + return code.rstrip() + else: + return "" def dumpmem(self, start, end): """ From caedb993b1d1ff165460052ff717850251ee8085 Mon Sep 17 00:00:00 2001 From: onedv Date: Wed, 18 May 2016 22:11:16 +0200 Subject: [PATCH 02/25] Fixed shellcode display for PY3 due to missing decode --- lib/shellcode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/shellcode.py b/lib/shellcode.py index 957e90b..1a20188 100644 --- a/lib/shellcode.py +++ b/lib/shellcode.py @@ -356,7 +356,7 @@ def display(self, shellcodeId): try: s.request("GET", "/shellcode/files/shellcode-"+str(shellcodeId)+".php") res = s.getresponse() - data = res.read().split("
")[1].split("")[0]
+            data = res.read().decode('utf-8').split("
")[1].split("")[0]
         except:
             error_msg("Failed to download shellcode from shell-storm.org")
             return None

From b7c7d7aeeba65a467fe982787b4f72e017774905 Mon Sep 17 00:00:00 2001
From: Long Le 
Date: Fri, 3 Jun 2016 08:51:55 +0700
Subject: [PATCH 03/25] Add depth limit to examine_mem_reference()

---
 peda.py | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/peda.py b/peda.py
index dc6f123..f525d52 100644
--- a/peda.py
+++ b/peda.py
@@ -50,7 +50,7 @@
     from urllib import urlopen
     from urllib import urlencode
     pyversion = 2
-	
+
 REGISTERS = {
     8 : ["al", "ah", "bl", "bh", "cl", "ch", "dl", "dh"],
     16: ["ax", "bx", "cx", "dx"],
@@ -1449,7 +1449,7 @@ def _get_allmaps_osx(pid, remote=False):
             if remote: # remote target, not yet supported
                 return maps
             else: # local target
-                try:  out = execute_external_command("vmmap -w %s" % self.getpid())
+                try:  out = execute_external_command("/usr/bin/vmmap -w %s" % self.getpid())
                 except: error_msg("could not read vmmap of process")
 
             matches = pattern.findall(out)
@@ -2142,7 +2142,7 @@ def examine_data(value, bits=32):
         return result
 
     @memoized
-    def examine_mem_reference(self, value):
+    def examine_mem_reference(self, value, depth=5):
         """
         Deeply examine a value in memory for its references
 
@@ -2153,8 +2153,16 @@ def examine_mem_reference(self, value):
             - list of tuple of (value(Int), type(String), next_value(Int))
         """
         result = []
+        if depth <= 0:
+            depth = 0xffffffff
+
         (v, t, vn) = self.examine_mem_value(value)
         while vn is not None:
+            if len(result) > depth:
+                _v, _t, _vn = result[-1]
+                result[-1] = (_v, _t, "--> ...")
+                break
+
             result += [(v, t, vn)]
             if v == vn or to_int(v) == to_int(vn): # point to self
                 break
@@ -4824,17 +4832,9 @@ def get_reg_text(r, v):
                 for r in REGISTERS[bits]:
                     if r in regs:
                         text += get_reg_text(r, regs[r])
-                        # text += green("%s" % r.upper().ljust(3)) + ": "
-                        # chain = peda.examine_mem_reference(regs[r])
-                        # text += format_reference_chain(chain)
-                        # text += "\n"
             else:
                 for (r, v) in sorted(regs.items()):
                     text += get_reg_text(r, v)
-                    # text += green("%s" % r.upper().ljust(3)) + ": "
-                    # chain = peda.examine_mem_reference(v)
-                    # text += format_reference_chain(chain)
-                    # text += "\n"
             if text:
                 msg(text.strip())
             if regname is None or "eflags" in regname:
@@ -4845,7 +4845,7 @@ def get_reg_text(r, v):
             warning_msg("not a register nor an address")
         else:
             # Address
-            chain = peda.examine_mem_reference(address)
+            chain = peda.examine_mem_reference(address, depth=0)
             text += format_reference_chain(chain) + "\n"
             vmrange = peda.get_vmrange(address)
             if vmrange:
@@ -5678,7 +5678,7 @@ def shellcode(self, *arg):
             MYNAME generate [arch/]platform type [port] [host]
             MYNAME search keyword (use % for any character wildcard)
             MYNAME display shellcodeId (shellcodeId as appears in search results)
-	    MYNAME zsc [generate customize shellcode] 
+	    MYNAME zsc [generate customize shellcode]
 
             For generate option:
                 default port for bindport shellcode: 16706 (0x4142)
@@ -5781,7 +5781,7 @@ def list_shellcode():
                         os = input('%s'%blue('os:'))
                     if pyversion is 3:
                         os = input('%s'%blue('os:'))
-                    if os in oslist: #check if os exist 
+                    if os in oslist: #check if os exist
                         break
                     else:
                         warning_msg("Wrong input! Try Again.")

From 0321d83ee91931d903d611bed166428a388d0419 Mon Sep 17 00:00:00 2001
From: Bret Barkley 
Date: Mon, 8 Aug 2016 14:08:42 +0000
Subject: [PATCH 04/25] Made the context info 'clear' so the screen is
 persistent (more tui-like)

---
 peda.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/peda.py b/peda.py
index f525d52..9f1d10b 100644
--- a/peda.py
+++ b/peda.py
@@ -4267,7 +4267,7 @@ def context_register(self, *arg):
 
         pc = peda.getreg("pc")
         # display register info
-        msg("[%s]" % "registers".center(78, "-"), "blue")
+        msg("\033[2J\033[0;0H [%s]" % "registers".center(78, "-"), "blue")
         self.xinfo("register")
 
         return

From c3e21056629834b59536ae1eee0d65761c9dc366 Mon Sep 17 00:00:00 2001
From: Grazfather 
Date: Thu, 25 Aug 2016 15:47:04 +0000
Subject: [PATCH 05/25] eflags: Add toggle option

---
 peda.py | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/peda.py b/peda.py
index 9f1d10b..3deee3d 100644
--- a/peda.py
+++ b/peda.py
@@ -1186,9 +1186,9 @@ def get_eflags(self):
 
         return flags
 
-    def set_eflags(self, flagname, value=True):
+    def set_eflags(self, flagname, value):
         """
-        Set/clear value of a flag register
+        Set/clear/toggle value of a flag register
 
         Returns:
             - True if success (Bool)
@@ -1208,6 +1208,8 @@ def set_eflags(self, flagname, value=True):
         flags = {"carry": "CF", "parity": "PF", "adjust": "AF", "zero": "ZF", "sign": "SF",
                     "trap": "TF", "interrupt": "IF", "direction": "DF", "overflow": "OF"}
 
+        flagname = flagname.lower()
+
         if flagname not in flags:
             return False
 
@@ -1215,7 +1217,8 @@ def set_eflags(self, flagname, value=True):
         if not eflags:
             return False
 
-        if eflags[flags[flagname]] != value: # switch value
+        # If value doesn't match the current, or we want to toggle, toggle
+        if value is None or eflags[flags[flagname]] != value:
             reg_eflags = self.getreg("eflags")
             reg_eflags ^= eval("EFLAGS_%s" % flags[flagname])
             result = self.execute("set $eflags = 0x%x" % reg_eflags)
@@ -4764,10 +4767,10 @@ def telescope(self, *arg):
 
     def eflags(self, *arg):
         """
-        Display/set/clear value of eflags register
+        Display/set/clear/toggle value of eflags register
         Usage:
             MYNAME
-            MYNAME [set|clear] flagname
+            MYNAME [set|clear|toggle] flagname
         """
         FLAGS = ["CF", "PF", "AF", "ZF", "SF", "TF", "IF", "DF", "OF"]
         FLAGS_TEXT = ["Carry", "Parity", "Adjust", "Zero", "Sign", "Trap",
@@ -4777,10 +4780,10 @@ def eflags(self, *arg):
         if not self._is_running():
             return
 
-        if option and not flagname:
+        elif option and not flagname:
             self._missing_argument()
 
-        if option is None: # display eflags
+        elif option is None: # display eflags
             flags = peda.get_eflags()
             text = ""
             for (i, f) in enumerate(FLAGS):
@@ -4792,14 +4795,17 @@ def eflags(self, *arg):
             eflags = peda.getreg("eflags")
             msg("%s: 0x%x (%s)" % (green("EFLAGS"), eflags, text.strip()))
 
-        if option == "set":
-            peda.set_eflags(flagname.lower())
+        elif option == "set":
+            peda.set_eflags(flagname, True)
 
-        if option == "clear":
+        elif option == "clear":
             peda.set_eflags(flagname, False)
 
+        elif option == "toggle":
+            peda.set_eflags(flagname, None)
+
         return
-    eflags.options = ["set", "clear"]
+    eflags.options = ["set", "clear", "toggle"]
 
     def xinfo(self, *arg):
         """

From 5458dd5ba8e2b86c20aed223678d916062dc335d Mon Sep 17 00:00:00 2001
From: Long Le 
Date: Wed, 25 Jan 2017 09:05:01 +0700
Subject: [PATCH 06/25] Fix "jmp reg" cases in eval_target()

---
 peda.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/peda.py b/peda.py
index 3deee3d..2fb36d2 100644
--- a/peda.py
+++ b/peda.py
@@ -1231,7 +1231,7 @@ def eval_target(self, inst):
         Evaluate target address of an instruction, used for jumpto decision
 
         Args:
-            - inst: AMS instruction text (String)
+            - inst: ASM instruction text (String)
 
         Returns:
             - target address (Int)
@@ -1244,10 +1244,11 @@ def eval_target(self, inst):
         p = re.compile(".*?:\s*[^ ]*\s*(.* PTR ).*(0x[^ ]*)")
         m = p.search(inst)
         if not m:
-            p = re.compile(".*?:\s.*(0x[^ ]*)")
+            p = re.compile(".*?:\s.*\s(0x[^ ]*|\w+)")
             m = p.search(inst)
             if m:
                 target = m.group(1)
+                target = self.parse_and_eval(target)
             else:
                 target = None
         else:

From a9098ea0503a2eb65a79dfddca3ded7c9b140fa8 Mon Sep 17 00:00:00 2001
From: Jean Privat 
Date: Tue, 21 Feb 2017 10:55:07 -0500
Subject: [PATCH 07/25] Fix small typo in doc in utils.py s/A-z/A-Z/

---
 lib/utils.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/utils.py b/lib/utils.py
index 767f132..ba0acd9 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -564,7 +564,7 @@ def cyclic_pattern_charset(charset_type=None):
 
     Args:
         - charset_type: charset type
-            0: basic (0-9A-za-z)
+            0: basic (0-9A-Za-z)
             1: extended (default)
             2: maximum (almost printable chars)
 
@@ -635,7 +635,7 @@ def cyclic_pattern(size=None, start=None, charset_type=None):
         - size: size of generated pattern (Int)
         - start: the start offset of the generated pattern (Int)
         - charset_type: charset type
-            0: basic (0-9A-za-z)
+            0: basic (0-9A-Za-z)
             1: extended (default)
             2: maximum (almost printable chars)
 

From 847a926b04e6580629db33f629f4431744e2de1b Mon Sep 17 00:00:00 2001
From: Long Le 
Date: Sat, 8 Apr 2017 13:36:24 +0700
Subject: [PATCH 08/25] Make "clearscreen" more reasonable and configurable

---
 lib/config.py | 1 +
 lib/utils.py  | 4 ++++
 peda.py       | 6 +++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/config.py b/lib/config.py
index 5704fc7..d50880c 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -35,6 +35,7 @@
     "autosave"  : ("on", "auto saving peda session, e.g: on|off"),
     "payload"   : ("peda-payload-#FILENAME#.txt", "target file to save output of payload command"),
     "context"   : ("register,code,stack", "context display setting, e.g: register, code, stack, all"),
+    "clearscr"  : ("on", "clear screen for each context display"),
     "verbose"   : ("off", "show detail execution of commands, e.g: on|off"),
     "debug"     : ("off", "show detail error of peda commands, e.g: on|off"),
     "_teefd"    : ("", "internal use only for tracelog/crashlog writing")
diff --git a/lib/utils.py b/lib/utils.py
index 767f132..62a4558 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -147,6 +147,10 @@ def blue(text, attrib=None):
     """Wrapper for colorize(text, 'blue')"""
     return colorize(text, "blue", attrib)
 
+def clearscreen():
+    """Clear terminal screen"""
+    sys.stdout.write("\x1b[2J\x1b[H")
+
 class message(object):
     """
     Generic pretty printer with redirection.
diff --git a/peda.py b/peda.py
index 2fb36d2..0215410 100644
--- a/peda.py
+++ b/peda.py
@@ -4271,7 +4271,7 @@ def context_register(self, *arg):
 
         pc = peda.getreg("pc")
         # display register info
-        msg("\033[2J\033[0;0H [%s]" % "registers".center(78, "-"), "blue")
+        msg("[%s]" % "registers".center(78, "-"), "blue")
         self.xinfo("register")
 
         return
@@ -4392,6 +4392,10 @@ def context(self, *arg):
         if not self._is_running():
             return
 
+        clearscr = config.Option.get("clearscr")
+        if clearscr == "on":
+            clearscreen()
+
         status = peda.get_status()
         # display registers
         if "reg" in opt or "register" in opt:

From bbf58727b467ccdc8db6c5c6e2459d4ce19c1724 Mon Sep 17 00:00:00 2001
From: Long Le 
Date: Tue, 23 May 2017 08:36:44 +0700
Subject: [PATCH 09/25] Fix regex in elfheader

---
 peda.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/peda.py b/peda.py
index 0215410..7c689c0 100644
--- a/peda.py
+++ b/peda.py
@@ -2260,7 +2260,7 @@ def elfheader(self, name=None):
         if not out:
             return {}
 
-        p = re.compile("\s*(0x[^-]*)->(0x[^ ]*) at (.*):\s*([^ ]*)\s*(.*)")
+        p = re.compile("\s*(0x[^-]*)->(0x[^ ]*) at (0x[^:]*):\s*([^ ]*)\s*(.*)")
         matches = p.findall(out)
 
         for (start, end, offset, hname, attr) in matches:

From dbb589727494225091775958c61dc993a9232cc6 Mon Sep 17 00:00:00 2001
From: Agahlot 
Date: Mon, 5 Feb 2018 23:30:05 +0530
Subject: [PATCH 10/25] fix telescope output

---
 peda.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/peda.py b/peda.py
index 7c689c0..8532828 100644
--- a/peda.py
+++ b/peda.py
@@ -4746,6 +4746,8 @@ def telescope(self, *arg):
 
         step = peda.intsize()
         if not peda.is_address(address): # cannot determine address
+            msg("Invalid $SP address: 0x%x" % sp, "red")
+            return
             for i in range(count):
                 if not peda.execute("x/%sx 0x%x" % ("g" if step == 8 else "w", address + i*step)):
                     break

From 82fcb5a12c92c27fc5722772a84df47b996d3d03 Mon Sep 17 00:00:00 2001
From: Agahlot 
Date: Mon, 5 Feb 2018 23:39:05 +0530
Subject: [PATCH 11/25] Fix: *address* instead of *sp*

---
 peda.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/peda.py b/peda.py
index 8532828..31eae61 100644
--- a/peda.py
+++ b/peda.py
@@ -4746,7 +4746,7 @@ def telescope(self, *arg):
 
         step = peda.intsize()
         if not peda.is_address(address): # cannot determine address
-            msg("Invalid $SP address: 0x%x" % sp, "red")
+            msg("Invalid $SP address: 0x%x" % address, "red")
             return
             for i in range(count):
                 if not peda.execute("x/%sx 0x%x" % ("g" if step == 8 else "w", address + i*step)):

From ade02aea696b90494f13a004ff2822229eb2a732 Mon Sep 17 00:00:00 2001
From: lambor <1973124271@qq.com>
Date: Fri, 25 May 2018 11:21:04 +0800
Subject: [PATCH 12/25] fix skeleton stdin cannot use modified environment

---
 lib/skeleton.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/skeleton.py b/lib/skeleton.py
index 123210f..20c30c5 100644
--- a/lib/skeleton.py
+++ b/lib/skeleton.py
@@ -150,7 +150,7 @@ def exploit(vuln):
     args = sys.argv[1:]
     resource.setrlimit(resource.RLIMIT_STACK, (-1, -1))
     resource.setrlimit(resource.RLIMIT_CORE, (-1, -1))
-    P = Popen(args, stdin=PIPE)
+    P = Popen(args, stdin=PIPE, env=env)
     P.stdin.write(payload + "\\n")
     while True:
         line = sys.stdin.readline()

From 7b7a8503bc5a468ea4990d02402b363f5508ed1a Mon Sep 17 00:00:00 2001
From: Quang Nguyen 
Date: Mon, 10 Sep 2018 15:24:32 +0700
Subject: [PATCH 13/25] set breakpoint at RVA from PIE base.

---
 peda.py | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/peda.py b/peda.py
index 31eae61..649bbf2 100644
--- a/peda.py
+++ b/peda.py
@@ -4417,6 +4417,26 @@ def context(self, *arg):
 
         return
 
+    def breakrva(self, *arg):
+        """
+        Set breakpoint by Relative Virtual Address (RVA)
+        Usage:
+            MYNAME rva
+            MYNAME rva module_name (e.g binary, shared module name)
+        """
+        (rva, module) = normalize_argv(arg, 2)
+        if rva is None or not to_int(rva):
+            self._missing_argument()
+        if module is None:
+            module = 'binary'
+
+        binmap = peda.get_vmmap(module)
+        if len(binmap) == 0:
+            print ("%s not found" % module)
+        else:
+            base_address = binmap[0][0]
+            peda.set_breakpoint(base_address+rva)
+        return
 
     #################################
     #   Memory Operation Commands   #
@@ -6146,6 +6166,7 @@ def sigint_handler(signal, frame):
 Alias("stack", "peda telescope $sp")
 Alias("viewmem", "peda telescope")
 Alias("reg", "peda xinfo register")
+Alias("brva", "breakrva")
 
 # misc gdb settings
 peda.execute("set confirm off")

From f7824e6c68431d3e9a9344a413a19f2d2a0bc0c1 Mon Sep 17 00:00:00 2001
From: Long Le 
Date: Sat, 15 Sep 2018 08:48:13 +0700
Subject: [PATCH 14/25] Update output msg of breakrva

---
 peda.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/peda.py b/peda.py
index 649bbf2..0dd91f4 100644
--- a/peda.py
+++ b/peda.py
@@ -4432,7 +4432,7 @@ def breakrva(self, *arg):
 
         binmap = peda.get_vmmap(module)
         if len(binmap) == 0:
-            print ("%s not found" % module)
+            msg("No module matches '%s'" % module)
         else:
             base_address = binmap[0][0]
             peda.set_breakpoint(base_address+rva)

From 2d7afd1d8b69f75820b049e691ccc34e20309111 Mon Sep 17 00:00:00 2001
From: Niboucha Redouane 
Date: Thu, 4 Oct 2018 00:45:52 +0100
Subject: [PATCH 15/25] Fixed a bug in the string_to_argv method

Fixed a bug where the lexer fails to parse a command like : patch "\x22"
---
 peda.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/peda.py b/peda.py
index 0dd91f4..122f5e0 100644
--- a/peda.py
+++ b/peda.py
@@ -195,8 +195,7 @@ def string_to_argv(self, str):
             str = str.encode('ascii', 'ignore')
         except:
             pass
-        str = decode_string_escape(str)
-        args = shlex.split(str)
+        args = list(map(lambda x: decode_string_escape(x), shlex.split(str.decode())))
         # need more processing here
         for idx, a in enumerate(args):
             a = a.strip(",")

From bfffa6307244616c4ac81b7a71fd33094b1d79b7 Mon Sep 17 00:00:00 2001
From: Niboucha Redouane 
Date: Fri, 8 Feb 2019 22:23:23 +0100
Subject: [PATCH 16/25] Fix peda.getpid() for remote debugging

Fixed peda.getpid() returning None when debugging remote processes, _is_running now returns true for remote processes, commands like telescope, vmmap, context etc. now work fine
---
 peda.py | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/peda.py b/peda.py
index 122f5e0..dfcd7cd 100644
--- a/peda.py
+++ b/peda.py
@@ -421,26 +421,6 @@ def getpid(self):
         status = self.get_status()
         if not status or status == "STOPPED":
             return None
-
-        if self.is_target_remote(): # remote target
-            ctx = config.Option.get("context")
-            config.Option.set("context", None)
-            try:
-                out = self.execute_redirect("call getpid()")
-            except:
-                pass
-
-            config.Option.set("context", ctx)
-
-            if out is None:
-                return None
-            else:
-                out = self.execute_redirect("print $")
-                if out:
-                    return to_int(out.split("=")[1])
-                else:
-                    return None
-
         pid = gdb.selected_inferior().pid
         return int(pid) if pid else None
 
@@ -3060,7 +3040,7 @@ def _is_running(self):
         """
         pid = peda.getpid()
         if pid is None:
-            text = "not running or target is remote"
+            text = "not running"
             warning_msg(text)
             return None
             #raise Exception(text)

From ce77916c58f1d80a1030c77e0fe79ced6def3aaf Mon Sep 17 00:00:00 2001
From: afg 
Date: Thu, 28 Nov 2019 19:28:54 +0800
Subject: [PATCH 17/25] fix: SyntaxWarning: "is" with a literal. Did you mean
 "=="?

---
 peda.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/peda.py b/peda.py
index dfcd7cd..14a7f5e 100644
--- a/peda.py
+++ b/peda.py
@@ -42,7 +42,7 @@
 import config
 from nasm import *
 
-if sys.version_info.major is 3:
+if sys.version_info.major == 3:
     from urllib.request import urlopen
     from urllib.parse import urlencode
     pyversion = 3
@@ -5789,9 +5789,9 @@ def list_shellcode():
                 while True:
                     for os in oslist:
                         msg('%s %s'%(yellow('[+]'),green(os)))
-                    if pyversion is 2:
+                    if pyversion == 2:
                         os = input('%s'%blue('os:'))
-                    if pyversion is 3:
+                    if pyversion == 3:
                         os = input('%s'%blue('os:'))
                     if os in oslist: #check if os exist
                         break
@@ -5800,9 +5800,9 @@ def list_shellcode():
                 while True:
                     for job in joblist:
                         msg('%s %s'%(yellow('[+]'),green(job)))
-                    if pyversion is 2:
+                    if pyversion == 2:
                         job = raw_input('%s'%blue('job:'))
-                    if pyversion is 3:
+                    if pyversion == 3:
                         job = input('%s'%blue('job:'))
                     if job != '':
                         break
@@ -5811,9 +5811,9 @@ def list_shellcode():
                 while True:
                     for encode in encodelist:
                         msg('%s %s'%(yellow('[+]'),green(encode)))
-                    if pyversion is 2:
+                    if pyversion == 2:
                         encode = raw_input('%s'%blue('encode:'))
-                    if pyversion is 3:
+                    if pyversion == 3:
                         encode = input('%s'%blue('encode:'))
                     if encode != '':
                         break

From 2f48add05b44743fe6a305abc446b648d5e805f8 Mon Sep 17 00:00:00 2001
From: Mihai-Valentin DUMITRU 
Date: Fri, 29 Nov 2019 17:14:16 +0200
Subject: [PATCH 18/25] silence python3.8 warnings

---
 peda.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/peda.py b/peda.py
index dfcd7cd..14a7f5e 100644
--- a/peda.py
+++ b/peda.py
@@ -42,7 +42,7 @@
 import config
 from nasm import *
 
-if sys.version_info.major is 3:
+if sys.version_info.major == 3:
     from urllib.request import urlopen
     from urllib.parse import urlencode
     pyversion = 3
@@ -5789,9 +5789,9 @@ def list_shellcode():
                 while True:
                     for os in oslist:
                         msg('%s %s'%(yellow('[+]'),green(os)))
-                    if pyversion is 2:
+                    if pyversion == 2:
                         os = input('%s'%blue('os:'))
-                    if pyversion is 3:
+                    if pyversion == 3:
                         os = input('%s'%blue('os:'))
                     if os in oslist: #check if os exist
                         break
@@ -5800,9 +5800,9 @@ def list_shellcode():
                 while True:
                     for job in joblist:
                         msg('%s %s'%(yellow('[+]'),green(job)))
-                    if pyversion is 2:
+                    if pyversion == 2:
                         job = raw_input('%s'%blue('job:'))
-                    if pyversion is 3:
+                    if pyversion == 3:
                         job = input('%s'%blue('job:'))
                     if job != '':
                         break
@@ -5811,9 +5811,9 @@ def list_shellcode():
                 while True:
                     for encode in encodelist:
                         msg('%s %s'%(yellow('[+]'),green(encode)))
-                    if pyversion is 2:
+                    if pyversion == 2:
                         encode = raw_input('%s'%blue('encode:'))
-                    if pyversion is 3:
+                    if pyversion == 3:
                         encode = input('%s'%blue('encode:'))
                     if encode != '':
                         break

From 6e87c911dcbd918338762cefbb59b503aed96140 Mon Sep 17 00:00:00 2001
From: duckie <40424574+not-duckie@users.noreply.github.com>
Date: Mon, 23 Dec 2019 16:40:11 +0530
Subject: [PATCH 19/25] changed is to ==

this python3 requirement to use == in place of 'is', otherwise it shows warning, it does affect the working but its anonying to warning everytime, so i fixed it.
---
 peda.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/peda.py b/peda.py
index dfcd7cd..14a7f5e 100644
--- a/peda.py
+++ b/peda.py
@@ -42,7 +42,7 @@
 import config
 from nasm import *
 
-if sys.version_info.major is 3:
+if sys.version_info.major == 3:
     from urllib.request import urlopen
     from urllib.parse import urlencode
     pyversion = 3
@@ -5789,9 +5789,9 @@ def list_shellcode():
                 while True:
                     for os in oslist:
                         msg('%s %s'%(yellow('[+]'),green(os)))
-                    if pyversion is 2:
+                    if pyversion == 2:
                         os = input('%s'%blue('os:'))
-                    if pyversion is 3:
+                    if pyversion == 3:
                         os = input('%s'%blue('os:'))
                     if os in oslist: #check if os exist
                         break
@@ -5800,9 +5800,9 @@ def list_shellcode():
                 while True:
                     for job in joblist:
                         msg('%s %s'%(yellow('[+]'),green(job)))
-                    if pyversion is 2:
+                    if pyversion == 2:
                         job = raw_input('%s'%blue('job:'))
-                    if pyversion is 3:
+                    if pyversion == 3:
                         job = input('%s'%blue('job:'))
                     if job != '':
                         break
@@ -5811,9 +5811,9 @@ def list_shellcode():
                 while True:
                     for encode in encodelist:
                         msg('%s %s'%(yellow('[+]'),green(encode)))
-                    if pyversion is 2:
+                    if pyversion == 2:
                         encode = raw_input('%s'%blue('encode:'))
-                    if pyversion is 3:
+                    if pyversion == 3:
                         encode = input('%s'%blue('encode:'))
                     if encode != '':
                         break

From ed42e840eff116be327489c9c395cf471267a2ca Mon Sep 17 00:00:00 2001
From: duckie <40424574+not-duckie@users.noreply.github.com>
Date: Mon, 23 Dec 2019 17:23:27 +0530
Subject: [PATCH 20/25] added information

---
 README.md | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 8878ab1..7b66773 100644
--- a/README.md
+++ b/README.md
@@ -29,9 +29,13 @@ PEDA - Python Exploit Development Assistance for GDB
 
 ## Installation
 
-    git clone https://github.com/longld/peda.git ~/peda
-    echo "source ~/peda/peda.py" >> ~/.gdbinit
+    git clone https://github.com/not-duckie/peda.git /opt/peda
+    echo "source /opt/peda/peda.py" >> ~/.gdbinit
     echo "DONE! debug your program with gdb and enjoy"
+Note:
+This is exaclty the clone of peda repositry by [longld]https://github.com/longld/peda but this one doesnt throw warning to
+use == instead of is when using with python3.
+I changed it as it was anonying and peda is a great project by [longld]https://github.com/longld/peda and above those warnings. 
 
 ## Screenshot
 ![start](http://i.imgur.com/P1BF5mp.png)

From 0612c40c17a5a23e9f70d1d7b4fe29c3b54e1afd Mon Sep 17 00:00:00 2001
From: duckie <40424574+not-duckie@users.noreply.github.com>
Date: Mon, 23 Dec 2019 17:24:12 +0530
Subject: [PATCH 21/25] markdown error

---
 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 7b66773..04d2669 100644
--- a/README.md
+++ b/README.md
@@ -33,9 +33,9 @@ PEDA - Python Exploit Development Assistance for GDB
     echo "source /opt/peda/peda.py" >> ~/.gdbinit
     echo "DONE! debug your program with gdb and enjoy"
 Note:
-This is exaclty the clone of peda repositry by [longld]https://github.com/longld/peda but this one doesnt throw warning to
+This is exaclty the clone of peda repositry by ![longld]https://github.com/longld/peda but this one doesnt throw warning to
 use == instead of is when using with python3.
-I changed it as it was anonying and peda is a great project by [longld]https://github.com/longld/peda and above those warnings. 
+I changed it as it was anonying and peda is a great project by ![longld]https://github.com/longld/peda and above those warnings. 
 
 ## Screenshot
 ![start](http://i.imgur.com/P1BF5mp.png)

From 8441afd4037367b29354481a917014746177d3d2 Mon Sep 17 00:00:00 2001
From: duckie <40424574+not-duckie@users.noreply.github.com>
Date: Mon, 23 Dec 2019 17:26:07 +0530
Subject: [PATCH 22/25] i wish i was fluent in markdown -_-

---
 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 04d2669..7919c2a 100644
--- a/README.md
+++ b/README.md
@@ -33,9 +33,9 @@ PEDA - Python Exploit Development Assistance for GDB
     echo "source /opt/peda/peda.py" >> ~/.gdbinit
     echo "DONE! debug your program with gdb and enjoy"
 Note:
-This is exaclty the clone of peda repositry by ![longld]https://github.com/longld/peda but this one doesnt throw warning to
+This is exaclty the clone of peda repositry by ![longld](https://github.com/longld/peda) but this one doesnt throw warning to
 use == instead of is when using with python3.
-I changed it as it was anonying and peda is a great project by ![longld]https://github.com/longld/peda and above those warnings. 
+I changed it as it was anonying and peda is a great project by ![longld](https://github.com/longld/peda) and above those warnings. 
 
 ## Screenshot
 ![start](http://i.imgur.com/P1BF5mp.png)

From 6de0f5f2b7669658fafd8e00d1333c1aa7e55b12 Mon Sep 17 00:00:00 2001
From: Long Le 
Date: Tue, 28 Jan 2020 07:33:40 +0700
Subject: [PATCH 23/25] Revert "changed "is" to "==""

---
 README.md |  8 ++------
 peda.py   | 14 +++++++-------
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/README.md b/README.md
index 7919c2a..8878ab1 100644
--- a/README.md
+++ b/README.md
@@ -29,13 +29,9 @@ PEDA - Python Exploit Development Assistance for GDB
 
 ## Installation
 
-    git clone https://github.com/not-duckie/peda.git /opt/peda
-    echo "source /opt/peda/peda.py" >> ~/.gdbinit
+    git clone https://github.com/longld/peda.git ~/peda
+    echo "source ~/peda/peda.py" >> ~/.gdbinit
     echo "DONE! debug your program with gdb and enjoy"
-Note:
-This is exaclty the clone of peda repositry by ![longld](https://github.com/longld/peda) but this one doesnt throw warning to
-use == instead of is when using with python3.
-I changed it as it was anonying and peda is a great project by ![longld](https://github.com/longld/peda) and above those warnings. 
 
 ## Screenshot
 ![start](http://i.imgur.com/P1BF5mp.png)
diff --git a/peda.py b/peda.py
index 14a7f5e..dfcd7cd 100644
--- a/peda.py
+++ b/peda.py
@@ -42,7 +42,7 @@
 import config
 from nasm import *
 
-if sys.version_info.major == 3:
+if sys.version_info.major is 3:
     from urllib.request import urlopen
     from urllib.parse import urlencode
     pyversion = 3
@@ -5789,9 +5789,9 @@ def list_shellcode():
                 while True:
                     for os in oslist:
                         msg('%s %s'%(yellow('[+]'),green(os)))
-                    if pyversion == 2:
+                    if pyversion is 2:
                         os = input('%s'%blue('os:'))
-                    if pyversion == 3:
+                    if pyversion is 3:
                         os = input('%s'%blue('os:'))
                     if os in oslist: #check if os exist
                         break
@@ -5800,9 +5800,9 @@ def list_shellcode():
                 while True:
                     for job in joblist:
                         msg('%s %s'%(yellow('[+]'),green(job)))
-                    if pyversion == 2:
+                    if pyversion is 2:
                         job = raw_input('%s'%blue('job:'))
-                    if pyversion == 3:
+                    if pyversion is 3:
                         job = input('%s'%blue('job:'))
                     if job != '':
                         break
@@ -5811,9 +5811,9 @@ def list_shellcode():
                 while True:
                     for encode in encodelist:
                         msg('%s %s'%(yellow('[+]'),green(encode)))
-                    if pyversion == 2:
+                    if pyversion is 2:
                         encode = raw_input('%s'%blue('encode:'))
-                    if pyversion == 3:
+                    if pyversion is 3:
                         encode = input('%s'%blue('encode:'))
                     if encode != '':
                         break

From c802397eccbbd745d9cf7eb729186a24131823a5 Mon Sep 17 00:00:00 2001
From: Ankit Das 
Date: Sat, 19 Dec 2020 19:37:41 +0530
Subject: [PATCH 24/25] Fixed Syntax Errors in Shellcode.py

Comparison between A variable and an integer was being done using 'is' whereas it should be done using '=='.
This has been fixed by replacing is with '=='.
---
 lib/shellcode.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/shellcode.py b/lib/shellcode.py
index 1a20188..6b87b0d 100644
--- a/lib/shellcode.py
+++ b/lib/shellcode.py
@@ -21,7 +21,7 @@
 import config
 from utils import msg, error_msg
 
-if sys.version_info.major is 3:
+if sys.version_info.major == 3:
     from urllib.request import urlopen
     from urllib.parse import urlencode
     pyversion = 3
@@ -376,7 +376,7 @@ def zsc(self,os,job,encode):
                     'job': job,
                     'encode': encode})
             shellcode = urlopen("http://api.z3r0d4y.com/index.py?%s\n"%(str(params))).read()
-            if pyversion is 3:
+            if pyversion == 3:
                 shellcode = str(shellcode,encoding='ascii')
             return '\n"'+shellcode.replace('\n','')+'"\n'
         except:

From 26cb228632b271777dc4eb2df27ebe0e214fcb21 Mon Sep 17 00:00:00 2001
From: Tim Gates 
Date: Thu, 24 Dec 2020 08:14:16 +1100
Subject: [PATCH 25/25] docs: fix simple typo, sequece -> sequence

There is a small typo in python23-compatibility.md.

Should read `sequence` rather than `sequece`.
---
 python23-compatibility.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python23-compatibility.md b/python23-compatibility.md
index e5b0036..d9b05a0 100644
--- a/python23-compatibility.md
+++ b/python23-compatibility.md
@@ -34,7 +34,7 @@ isinstance(x, six.integer_types)
 ## Strings
 
 In Python 2, `bytes` is an alias for `str`. In Python 3, `str` is a unicode
-type and `bytes` is used for a sequece of arbitrary bytes. Use a leading 'b' to
+type and `bytes` is used for a sequence of arbitrary bytes. Use a leading 'b' to
 signify that a string is a `bytes` object.
 
 ```python