ShawnDEvans / smbmap

SMBMap is a handy SMB enumeration tool
GNU General Public License v3.0
1.8k stars 346 forks source link

Multiple syntax warnings #100

Closed saltasatelites closed 5 months ago

saltasatelites commented 6 months ago

Hello. I just reinstalled smbmap (haven't been playing CTF for a while) and am getting a lot of syntax warnings. Running on Arch Linux with the latest updates and with all dependencies installed by Pacman. Smbmap cloned from GitHub. Smbmap works as expected. The warnings appear before SMBMAP starts running.. I've also run it in a Python environment with the same results. Python version 3.12.3

Thanks in advance


[me@Archlinux smbmap]$ python smbmap.py -H 192.168.1.140 -u admin -p 123asdf
/home/me/pentest/smbmap/smbmap/smbmap.py:441: SyntaxWarning: invalid escape sequence '\p'
  stringbinding = 'ncacn_np:%s[\pipe\svcctl]' % remoteName
/home/me/pentest/smbmap/smbmap/smbmap.py:640: SyntaxWarning: invalid escape sequence '\*'
  tmp_bat_cmd = 'powershell -NoLogo -ExecutionPolicy bypass -Command " & {}Get-ChildItem {}\*.* -Recurse -Exclude *.dll,*.exe,*.msi,*.jpg,*.gif,*.bmp,*.png,*.mp3,*.wav | Select-String -Pattern \'{}\' | Select-Object -Unique Path | out-string -width 220{}" 2>nul > {}\{}.txt'.format('{', search_path, pattern, '}', tmp_dir, job_name)
/home/me/pentest/smbmap/smbmap/smbmap.py:647: SyntaxWarning: invalid escape sequence '\{'
  print('[+] Job {} started on {}, result will be stored at {}\{}.txt'.format(job_name, host, tmp_dir, job_name))
/home/me/pentest/smbmap/smbmap/smbmap.py:662: SyntaxWarning: invalid escape sequence '\{'
  file_path = '{}\{}.txt'.format(path, job)
/home/me/pentest/smbmap/smbmap/smbmap.py:680: SyntaxWarning: invalid escape sequence '\{'
  isItThere = self.exec_command(self.jobs[job]['host'], self.jobs[job]['share'], 'cmd /c "if exist {}\{}.txt echo ImHere"'.format(self.jobs[job]['tmp'], job), disp_output=False)
/home/me/pentest/smbmap/smbmap/smbmap.py:681: SyntaxWarning: invalid escape sequence '\{'
  result = self.exec_command(self.jobs[job]['host'], self.jobs[job]['share'], 'cmd /c "2>nul (>>{}\{}.txt (call )) && (echo not locked) || (echo locked)"'.format(self.jobs[job]['tmp'], job), disp_output=False)
/home/me/pentest/smbmap/smbmap/smbmap.py:683: SyntaxWarning: invalid escape sequence '\%'
  dl_target = '%s%s\%s.txt' % (self.jobs[job]['share'], self.jobs[job]['tmp'][2:], job)
/home/me/pentest/smbmap/smbmap/smbmap.py1324: SyntaxWarning: invalid escape sequence '\p'
  mex_group2.add_argument("-r", metavar="PATH", dest="recursive_dir_list", nargs="?", const='/', help="Recursively list dirs and files (no share\path lists the root of ALL shares), ex. 'email/backup'")

/"       )|"  \    /"  ||   _  "\ |"  \    /"  |     /""\       |   __ "\
  (:   \___/  \   \  //   |(. |_)  🙂 \   \  //   |    /    \      (. |__) 🙂
   \___  \    /\  \/.    ||:     \/   /\   \/.    |   /' /\  \     |:  ____/
    __/  \   |: \.        |(|  _  \  |: \.        |  //  __'  \    (|  /
   /" \   🙂 |.  \    /:  ||: |_)  :)|.  \    /:  | /   /  \   \  /|__/ \
  (_______/  |___|\__/|___|(_______/ |___|\__/|___|(___/    \___)(_______)

-----------------------------------------------------------------------------
SMBMap - Samba Share Enumerator v1.10.2 | Shawn Evans - ShawnDEvans@gmail.com<mailto:ShawnDEvans@gmail.com>
                     https://github.com/ShawnDEvans/smbmap

[\] Checking for open ports...        [*] Detected 1 hosts serving SMB
[|] Initializing hosts...             [*] Established 1 SMB connections(s) and 1 authenticated session(s)
[/] Authenticating...                 [!] Access denied on 192.168.1.140, no fun for you...
[-] Closing connections..             [\] Closing connections..                                                                                                                                             [|] Closing connections..        [/] Closing connections..     
.......
ShawnDEvans commented 5 months ago

Weird, I just pushed a fresh update (1.10.3). You could try updating, but I didn't address any errors like you observed. I'll try to reproduce your errors and keep you posted. Thanks for the bug report!

I think this is related more specifically to Python 3.12+ and I'm doing dev in 3.10.12. According to Stack I'm a bit loose with escaping characters, which results in the SyntaxWarnings. I'll stand-up a VM with 3.12 and see what I get. Thanks again!

r4um commented 5 months ago

It has become syntax error since Python 3.12, see https://stackoverflow.com/a/77531416.

saltasatelites commented 5 months ago

Hello. Thanks @ShawnDEvans @r4um. I've just read the link to Stack and I guess it solves this ssue. I close it as completed.

ShawnDEvans commented 5 months ago

I ended up pushing a few changes to address the wonky escape sequences. Should be AOK in 3.12 now.

saltasatelites commented 5 months ago

All syntax warning have disappeared with the last update. Thanks a lot !!