Last active
October 22, 2022 09:26
-
-
Save lovemyliwu/48eeaf566978ec24843b743877df0021 to your computer and use it in GitHub Desktop.
Revisions
-
lovemyliwu revised this gist
Oct 22, 2022 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,13 +6,13 @@ def main(argv): parser = OptionParser() parser.add_option("-u", "--username", help="windows username that will be used for authentication") parser.add_option("-p", "--password", help="windows password that will be used for authentication") parser.add_option("-s", "--system-name", help="smb server machine name") parser.add_option("-d", "--domain", help="windows domain name that will be used for authentication") (options, args) = parser.parse_args() system_name = options.system_name -
lovemyliwu revised this gist
Oct 22, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ def main(argv): parser.add_option("-p", "--password", help="Password that will be used for authentication") parser.add_option("-s", "--system-name", help="windows domain name") parser.add_option("-d", "--domain", help="Domain name that will be used for authentication") (options, args) = parser.parse_args() -
lovemyliwu created this gist
Oct 22, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ import sys from optparse import OptionParser from smb.SMBConnection import SMBConnection def main(argv): parser = OptionParser() parser.add_option("-u", "--username", help="Username that will be used for authentication") parser.add_option("-p", "--password", help="Password that will be used for authentication") parser.add_option("-s", "--system-name", help="Read systems list from file") parser.add_option("-d", "--domain", help="Domain name that will be used for authentication") (options, args) = parser.parse_args() system_name = options.system_name try: print('### Analyzing system: ' + system_name) # parameterize an smb connection with a system conn = SMBConnection(options.username, options.password, 'enumerator', options.system_name, options.domain, use_ntlm_v2=True, sign_options=SMBConnection.SIGN_WHEN_SUPPORTED, is_direct_tcp=True) # establish the actual connection connected = conn.connect(system_name,445) try: Response = conn.listShares(timeout=30) # obtain a list of shares print('Shares on: ' + system_name) for i in range(len(Response)): # iterate through the list of shares print(" Share[",i,"] =", Response[i].name) try: # list the files on each share (recursivity?) Response2 = conn.listPath(Response[i].name,'/',timeout=30) print(' Files on: ' + system_name + '/' + " Share[",i,"] =", Response[i].name) for i in range(len(Response2)): print(" File[",i,"] =", Response2[i].filename) except: print('### can not access the resource') except Exception as error: print('### can not list shares') except: print('### can not access the system') if __name__ == "__main__": main(sys.argv[1:])