Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxWarning: invalid escape sequence #177

Open
aNaoy opened this issue May 4, 2024 · 8 comments
Open

SyntaxWarning: invalid escape sequence #177

aNaoy opened this issue May 4, 2024 · 8 comments

Comments

@aNaoy
Copy link

aNaoy commented May 4, 2024

There's a SyntaxWarning since Python 3.12 using peda.py at GDB startup. This was introduced here when the DeprecationWarning was upgraded to SyntaxWarning.

/usr/share/peda/peda.py:151: SyntaxWarning: invalid escape sequence '['
p = re.compile("(.)[(.)]") # DWORD PTR [esi+eax1]
/usr/share/peda/peda.py:373: SyntaxWarning: invalid escape sequence '\s'
p = re.compile(".exec file:\s`(.
)'")
/usr/share/peda/peda.py:550: SyntaxWarning: invalid escape sequence '\d'
p = re.compile("^(\d*)\s*(.breakpoint)\s(keep|del)\s*(y|n)\s*(0x[^ ])\s(.*)")
[...]

It should be fixed by using raw string literals (r"...").

@k1gen
Copy link

k1gen commented May 6, 2024

can confirm. Arch, gdb 14.2:

$ cat .gdbinit
set debuginfod enabled on
set disassembly-flavor intel
source ~/.peda/peda.py
$ gdb
/home/olk/.peda/peda.py:151: SyntaxWarning: invalid escape sequence '\['
  p = re.compile("(.*)\[(.*)\]") # DWORD PTR [esi+eax*1]
/home/olk/.peda/peda.py:373: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*exec file:\s*`(.*)'")
/home/olk/.peda/peda.py:550: SyntaxWarning: invalid escape sequence '\d'
  p = re.compile("^(\d*)\s*(.*breakpoint)\s*(keep|del)\s*(y|n)\s*(0x[^ ]*)\s*(.*)")
/home/olk/.peda/peda.py:554: SyntaxWarning: invalid escape sequence '\d'
  p = re.compile("^(\d*)\s*(.*point)\s*(keep|del)\s*(y|n)\s*(.*)")
/home/olk/.peda/peda.py:567: SyntaxWarning: invalid escape sequence '\d'
  m = re.match("in.*at(.*:\d*)", what)
/home/olk/.peda/peda.py:596: SyntaxWarning: invalid escape sequence '\d'
  m = re.match("^(\d*).*", line)
/home/olk/.peda/peda.py:916: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("\s*(0x[^ ]*).*?:\s*([^ ]*)\s*(.*)")
/home/olk/.peda/peda.py:918: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("(.*?)\s*<.*?>\s*([^ ]*)\s*(.*)")
/home/olk/.peda/peda.py:937: SyntaxWarning: invalid escape sequence '\['
  p = re.compile(".*mov.*\[esp(.*)\],")
/home/olk/.peda/peda.py:969: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(":\s*([^ ]*)\s*(.*),")
/home/olk/.peda/peda.py:1116: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s*(.*)")
/home/olk/.peda/peda.py:1223: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s*[^ ]*\s*(.* PTR ).*(0x[^ ]*)")
/home/olk/.peda/peda.py:1226: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s.*\s(0x[^ ]*|\w+)")
/home/olk/.peda/peda.py:1235: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s*[^ ]*\s*(.* PTR ).*\[(.*)\]")
/home/olk/.peda/peda.py:1430: SyntaxWarning: invalid escape sequence '\s'
  pattern = re.compile("([^\n]*)\s*  ([0-9a-f][^-\s]*)-([^\s]*) \[.*\]\s([^/]*).*  (.*)")
/home/olk/.peda/peda.py:2096: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?0x[^ ]*?\s(.*)")
/home/olk/.peda/peda.py:2114: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?0x[^ ]*?\s(.*)")
/home/olk/.peda/peda.py:2214: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("Entry point: ([^\s]*)")
/home/olk/.peda/peda.py:2242: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("\s*(0x[^-]*)->(0x[^ ]*) at (0x[^:]*):\s*([^ ]*)\s*(.*)")
/home/olk/.peda/peda.py:2316: SyntaxWarning: invalid escape sequence '\s'
  m = re.findall(".*(0x[^ ]*)\s*%s" % re.escape(symname), out)
/home/olk/.peda/peda.py:2416: SyntaxWarning: invalid escape sequence '\['
  p = re.compile(".*\[.*\] (\.[^ ]*) [^0-9]* ([^ ]*) [^ ]* ([^ ]*)(.*)")
/home/olk/.peda/peda.py:2474: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("[^\n]*\s*(0x[^ ]*) - (0x[^ ]*) is (\.[^ ]*) in (.*)")
/home/olk/.peda/peda.py:2681: SyntaxWarning: invalid escape sequence '\ '
  if re.search(re.escape(asmcode).replace("\ ",".*").replace("\?",".*"), asmcode_rs)\
/home/olk/.peda/peda.py:2681: SyntaxWarning: invalid escape sequence '\?'
  if re.search(re.escape(asmcode).replace("\ ",".*").replace("\?",".*"), asmcode_rs)\
/home/olk/.peda/peda.py:2832: SyntaxWarning: invalid escape sequence '\ '
  pattern = re.compile(b'|'.join(JMPCALL).replace(b' ', b'\ '))
/home/olk/.peda/peda.py:3414: SyntaxWarning: invalid escape sequence '\['
  m = re.search(".*\[(.*)\]|.*?s:(0x[^ ]*)", exp)
/home/olk/.peda/peda.py:3519: SyntaxWarning: invalid escape sequence '\['
  sock = re.search("socket:\[(.*)\]", rpath)
/home/olk/.peda/peda.py:3529: SyntaxWarning: invalid escape sequence '\s'
  ppid = re.search("PPid:\s*([^\s]*)", status).group(1)
/home/olk/.peda/peda.py:3531: SyntaxWarning: invalid escape sequence '\s'
  uid = re.search("Uid:\s*([^\n]*)", status).group(1)
/home/olk/.peda/peda.py:3533: SyntaxWarning: invalid escape sequence '\s'
  gid = re.search("Gid:\s*([^\n]*)", status).group(1)
/home/olk/.peda/peda.py:4125: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s*[^ ]*\s*([^,]*),(.*)")
Traceback (most recent call last):
  File "/home/olk/.peda/peda.py", line 30, in <module>
    from six.moves import range
ModuleNotFoundError: No module named 'six.moves'
(gdb)

@zetef
Copy link

zetef commented May 12, 2024

can confirm. Arch, gdb 14.2:

$ cat .gdbinit
set debuginfod enabled on
set disassembly-flavor intel
source ~/.peda/peda.py
$ gdb
/home/olk/.peda/peda.py:151: SyntaxWarning: invalid escape sequence '\['
  p = re.compile("(.*)\[(.*)\]") # DWORD PTR [esi+eax*1]
/home/olk/.peda/peda.py:373: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*exec file:\s*`(.*)'")
/home/olk/.peda/peda.py:550: SyntaxWarning: invalid escape sequence '\d'
  p = re.compile("^(\d*)\s*(.*breakpoint)\s*(keep|del)\s*(y|n)\s*(0x[^ ]*)\s*(.*)")
/home/olk/.peda/peda.py:554: SyntaxWarning: invalid escape sequence '\d'
  p = re.compile("^(\d*)\s*(.*point)\s*(keep|del)\s*(y|n)\s*(.*)")
/home/olk/.peda/peda.py:567: SyntaxWarning: invalid escape sequence '\d'
  m = re.match("in.*at(.*:\d*)", what)
/home/olk/.peda/peda.py:596: SyntaxWarning: invalid escape sequence '\d'
  m = re.match("^(\d*).*", line)
/home/olk/.peda/peda.py:916: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("\s*(0x[^ ]*).*?:\s*([^ ]*)\s*(.*)")
/home/olk/.peda/peda.py:918: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("(.*?)\s*<.*?>\s*([^ ]*)\s*(.*)")
/home/olk/.peda/peda.py:937: SyntaxWarning: invalid escape sequence '\['
  p = re.compile(".*mov.*\[esp(.*)\],")
/home/olk/.peda/peda.py:969: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(":\s*([^ ]*)\s*(.*),")
/home/olk/.peda/peda.py:1116: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s*(.*)")
/home/olk/.peda/peda.py:1223: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s*[^ ]*\s*(.* PTR ).*(0x[^ ]*)")
/home/olk/.peda/peda.py:1226: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s.*\s(0x[^ ]*|\w+)")
/home/olk/.peda/peda.py:1235: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s*[^ ]*\s*(.* PTR ).*\[(.*)\]")
/home/olk/.peda/peda.py:1430: SyntaxWarning: invalid escape sequence '\s'
  pattern = re.compile("([^\n]*)\s*  ([0-9a-f][^-\s]*)-([^\s]*) \[.*\]\s([^/]*).*  (.*)")
/home/olk/.peda/peda.py:2096: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?0x[^ ]*?\s(.*)")
/home/olk/.peda/peda.py:2114: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?0x[^ ]*?\s(.*)")
/home/olk/.peda/peda.py:2214: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("Entry point: ([^\s]*)")
/home/olk/.peda/peda.py:2242: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("\s*(0x[^-]*)->(0x[^ ]*) at (0x[^:]*):\s*([^ ]*)\s*(.*)")
/home/olk/.peda/peda.py:2316: SyntaxWarning: invalid escape sequence '\s'
  m = re.findall(".*(0x[^ ]*)\s*%s" % re.escape(symname), out)
/home/olk/.peda/peda.py:2416: SyntaxWarning: invalid escape sequence '\['
  p = re.compile(".*\[.*\] (\.[^ ]*) [^0-9]* ([^ ]*) [^ ]* ([^ ]*)(.*)")
/home/olk/.peda/peda.py:2474: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("[^\n]*\s*(0x[^ ]*) - (0x[^ ]*) is (\.[^ ]*) in (.*)")
/home/olk/.peda/peda.py:2681: SyntaxWarning: invalid escape sequence '\ '
  if re.search(re.escape(asmcode).replace("\ ",".*").replace("\?",".*"), asmcode_rs)\
/home/olk/.peda/peda.py:2681: SyntaxWarning: invalid escape sequence '\?'
  if re.search(re.escape(asmcode).replace("\ ",".*").replace("\?",".*"), asmcode_rs)\
/home/olk/.peda/peda.py:2832: SyntaxWarning: invalid escape sequence '\ '
  pattern = re.compile(b'|'.join(JMPCALL).replace(b' ', b'\ '))
/home/olk/.peda/peda.py:3414: SyntaxWarning: invalid escape sequence '\['
  m = re.search(".*\[(.*)\]|.*?s:(0x[^ ]*)", exp)
/home/olk/.peda/peda.py:3519: SyntaxWarning: invalid escape sequence '\['
  sock = re.search("socket:\[(.*)\]", rpath)
/home/olk/.peda/peda.py:3529: SyntaxWarning: invalid escape sequence '\s'
  ppid = re.search("PPid:\s*([^\s]*)", status).group(1)
/home/olk/.peda/peda.py:3531: SyntaxWarning: invalid escape sequence '\s'
  uid = re.search("Uid:\s*([^\n]*)", status).group(1)
/home/olk/.peda/peda.py:3533: SyntaxWarning: invalid escape sequence '\s'
  gid = re.search("Gid:\s*([^\n]*)", status).group(1)
/home/olk/.peda/peda.py:4125: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s*[^ ]*\s*([^,]*),(.*)")
Traceback (most recent call last):
  File "/home/olk/.peda/peda.py", line 30, in <module>
    from six.moves import range
ModuleNotFoundError: No module named 'six.moves'
(gdb)

can confirm the invalid sequence warnings.
regarding the error for module six I recommend force reinstalling the peda package from pacman

@punixcorn
Copy link

1.for SyntaxWarning

you can fix this by adding r to the strings
eg

 p = re.compile(r"(.*)\[(.*)\]") # DWORD PTR [esi+eax*1]

to make it raw string, pull request #178 fixes this.


2.for six.moves not found

you can use

pip install six

or if using arch, install from the repos

sudo pacman -S python-six

and remove the six.py in the lib
so it uses the global ones and not the local one found in lib

punixcorn added a commit to punixcorn/peda that referenced this issue Jul 4, 2024
punixcorn added a commit to punixcorn/peda that referenced this issue Jul 4, 2024
@liudonghua123
Copy link

liudonghua123 commented Oct 28, 2024

I have the similar issue, it seems to be the new python's behavior. see https://stackoverflow.com/questions/52335970/how-to-fix-syntaxwarning-invalid-escape-sequence-in-python.

Need to update the code!!!

You can also disable this warnings by using export PYTHONWARNINGS="ignore", see https://stackoverflow.com/questions/14463277/how-to-disable-python-warnings#:~:text=e.%20python%202.7)-,export%20PYTHONWARNINGS%3D%22ignore%22,-Test%20like%20this.

Details
└─$ gdb ./stack_overflow_32
GNU gdb (Debian 13.2-1+b2) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
/home/liudonghua/peda/peda.py:151: SyntaxWarning: invalid escape sequence '\['
  p = re.compile("(.*)\[(.*)\]") # DWORD PTR [esi+eax*1]
/home/liudonghua/peda/peda.py:373: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*exec file:\s*`(.*)'")
/home/liudonghua/peda/peda.py:550: SyntaxWarning: invalid escape sequence '\d'
  p = re.compile("^(\d*)\s*(.*breakpoint)\s*(keep|del)\s*(y|n)\s*(0x[^ ]*)\s*(.*)")
/home/liudonghua/peda/peda.py:554: SyntaxWarning: invalid escape sequence '\d'
  p = re.compile("^(\d*)\s*(.*point)\s*(keep|del)\s*(y|n)\s*(.*)")
/home/liudonghua/peda/peda.py:567: SyntaxWarning: invalid escape sequence '\d'
  m = re.match("in.*at(.*:\d*)", what)
/home/liudonghua/peda/peda.py:596: SyntaxWarning: invalid escape sequence '\d'
  m = re.match("^(\d*).*", line)
/home/liudonghua/peda/peda.py:916: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("\s*(0x[^ ]*).*?:\s*([^ ]*)\s*(.*)")
/home/liudonghua/peda/peda.py:918: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("(.*?)\s*<.*?>\s*([^ ]*)\s*(.*)")
/home/liudonghua/peda/peda.py:937: SyntaxWarning: invalid escape sequence '\['
  p = re.compile(".*mov.*\[esp(.*)\],")
/home/liudonghua/peda/peda.py:969: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(":\s*([^ ]*)\s*(.*),")
/home/liudonghua/peda/peda.py:1116: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s*(.*)")
/home/liudonghua/peda/peda.py:1223: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s*[^ ]*\s*(.* PTR ).*(0x[^ ]*)")
/home/liudonghua/peda/peda.py:1226: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s.*\s(0x[^ ]*|\w+)")
/home/liudonghua/peda/peda.py:1235: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s*[^ ]*\s*(.* PTR ).*\[(.*)\]")
/home/liudonghua/peda/peda.py:1430: SyntaxWarning: invalid escape sequence '\s'
  pattern = re.compile("([^\n]*)\s*  ([0-9a-f][^-\s]*)-([^\s]*) \[.*\]\s([^/]*).*  (.*)")
/home/liudonghua/peda/peda.py:2096: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?0x[^ ]*?\s(.*)")
/home/liudonghua/peda/peda.py:2114: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?0x[^ ]*?\s(.*)")
/home/liudonghua/peda/peda.py:2214: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("Entry point: ([^\s]*)")
/home/liudonghua/peda/peda.py:2242: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("\s*(0x[^-]*)->(0x[^ ]*) at (0x[^:]*):\s*([^ ]*)\s*(.*)")
/home/liudonghua/peda/peda.py:2316: SyntaxWarning: invalid escape sequence '\s'
  m = re.findall(".*(0x[^ ]*)\s*%s" % re.escape(symname), out)
/home/liudonghua/peda/peda.py:2416: SyntaxWarning: invalid escape sequence '\['
  p = re.compile(".*\[.*\] (\.[^ ]*) [^0-9]* ([^ ]*) [^ ]* ([^ ]*)(.*)")
/home/liudonghua/peda/peda.py:2474: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile("[^\n]*\s*(0x[^ ]*) - (0x[^ ]*) is (\.[^ ]*) in (.*)")
/home/liudonghua/peda/peda.py:2681: SyntaxWarning: invalid escape sequence '\ '
  if re.search(re.escape(asmcode).replace("\ ",".*").replace("\?",".*"), asmcode_rs)\
/home/liudonghua/peda/peda.py:2681: SyntaxWarning: invalid escape sequence '\?'
  if re.search(re.escape(asmcode).replace("\ ",".*").replace("\?",".*"), asmcode_rs)\
/home/liudonghua/peda/peda.py:2832: SyntaxWarning: invalid escape sequence '\ '
  pattern = re.compile(b'|'.join(JMPCALL).replace(b' ', b'\ '))
/home/liudonghua/peda/peda.py:3414: SyntaxWarning: invalid escape sequence '\['
  m = re.search(".*\[(.*)\]|.*?s:(0x[^ ]*)", exp)
/home/liudonghua/peda/peda.py:3519: SyntaxWarning: invalid escape sequence '\['
  sock = re.search("socket:\[(.*)\]", rpath)
/home/liudonghua/peda/peda.py:3529: SyntaxWarning: invalid escape sequence '\s'
  ppid = re.search("PPid:\s*([^\s]*)", status).group(1)
/home/liudonghua/peda/peda.py:3531: SyntaxWarning: invalid escape sequence '\s'
  uid = re.search("Uid:\s*([^\n]*)", status).group(1)
/home/liudonghua/peda/peda.py:3533: SyntaxWarning: invalid escape sequence '\s'
  gid = re.search("Gid:\s*([^\n]*)", status).group(1)
/home/liudonghua/peda/peda.py:4125: SyntaxWarning: invalid escape sequence '\s'
  p = re.compile(".*?:\s*[^ ]*\s*([^,]*),(.*)")
Traceback (most recent call last):
  File "/home/liudonghua/peda/peda.py", line 30, in <module>
    from six.moves import range
ModuleNotFoundError: No module named 'six.moves'
Reading symbols from ./stack_overflow_32...
(gdb) exit

┌──(liudonghua㉿DESKTOP-9DGFF40)-[~/ctf]
└─$
┌──(liudonghua㉿DESKTOP-9DGFF40)-[~/ctf]
└─$ export PYTHONWARNINGS="ignore"

┌──(liudonghua㉿DESKTOP-9DGFF40)-[~/ctf]
└─$ gdb ./stack_overflow_32
GNU gdb (Debian 13.2-1+b2) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Traceback (most recent call last):
  File "/home/liudonghua/peda/peda.py", line 30, in <module>
    from six.moves import range
ModuleNotFoundError: No module named 'six.moves'
Reading symbols from ./stack_overflow_32...
(gdb)

@liudonghua123
Copy link

And for ModuleNotFoundError: No module named 'six.moves' issue, I tried python3.12 -m pip install six but it doesn't work, and I fixed by cp /usr/lib/python3/dist-packages/six.py /home/liudonghua/peda/lib/six.py finally.

Details
┌──(liudonghua㉿DESKTOP-9DGFF40)-[~/ctf]
└─$ gdb
GNU gdb (Debian 13.2-1+b2) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Traceback (most recent call last):
  File "/home/liudonghua/peda/peda.py", line 30, in <module>
    from six.moves import range
ModuleNotFoundError: No module named 'six.moves'
(gdb) python import sys; print(sys.path)
['/home/liudonghua/peda/lib/', '/usr/share/gdb/python', '/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/usr/local/lib/python3.12/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.12/dist-packages']
(gdb) from six.moves import range
Undefined command: "from".  Try "help".
(gdb) python from six.moves import range
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'six.moves'
Error while executing Python code.
(gdb) python import six; print(six.__file__)
/home/liudonghua/peda/lib/six.py
(gdb) exit

┌──(liudonghua㉿DESKTOP-9DGFF40)-[~/ctf]
└─$ python3.12
Python 3.12.4 (main, Jul 15 2024, 12:17:32) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import six
>>> from six.moves import range
>>> six.__file__
'/usr/lib/python3/dist-packages/six.py'
>>> exit()

┌──(liudonghua㉿DESKTOP-9DGFF40)-[~/ctf]
└─$ ll /usr/lib/python3/dist-packages/six.py /home/liudonghua/peda/lib/six.py
-rw-r--r-- 1 liudonghua liudonghua 34549 Oct 28 22:24 /home/liudonghua/peda/lib/six.py
-rw-r--r-- 1 root       root       34549 Mar 16  2024 /usr/lib/python3/dist-packages/six.py

┌──(liudonghua㉿DESKTOP-9DGFF40)-[~/ctf]
└─$

┌──(liudonghua㉿DESKTOP-9DGFF40)-[~/ctf]
└─$ cp /home/liudonghua/peda/lib/six.py /home/liudonghua/peda/lib/six.py.old

┌──(liudonghua㉿DESKTOP-9DGFF40)-[~/ctf]
└─$ cp /usr/lib/python3/dist-packages/six.py /home/liudonghua/peda/lib/six.py

┌──(liudonghua㉿DESKTOP-9DGFF40)-[~/ctf]
└─$ gdb
GNU gdb (Debian 13.2-1+b2) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
gdb-peda$

@zhaoxy0118
Copy link

it's not work my pc
image

@liudonghua123
Copy link

it's not work my pc
image

from the picture, i didn't see such error like ModuleNotFoundError: No module named 'six.moves', and it's working for you.

@zhaoxy0118
Copy link

zhaoxy0118 commented Nov 18, 2024

oh,yes,it's working for me。Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants