mirror of
git://git.acid.vegas/IRCP.git
synced 2024-11-26 01:46:39 +00:00
Improved ban detections & added SSL/TLS cipher logging
This commit is contained in:
parent
7ace89b659
commit
3f66438ebe
52
ircp.py
52
ircp.py
@ -53,6 +53,26 @@ badchan = {
|
|||||||
'520' : 'ERR_OPERONLY', '926' : 'ERR_BADCHANNEL'
|
'520' : 'ERR_OPERONLY', '926' : 'ERR_BADCHANNEL'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
badserver = {
|
||||||
|
'install identd' : 'Identd required',
|
||||||
|
'trying to reconnect too fast' : 'Throttled',
|
||||||
|
'your host is trying to (re)connect too fast' : 'Throttled',
|
||||||
|
'reconnecting too fast' : 'Throttled',
|
||||||
|
'access denied' : 'Access denied',
|
||||||
|
'not authorized to' : 'Not authorized',
|
||||||
|
'not authorised to' : 'Not authorized',
|
||||||
|
'password mismatch' : 'Password mismatch',
|
||||||
|
'dronebl' : 'DroneBL',
|
||||||
|
'dnsbl' : 'DNSBL',
|
||||||
|
'g:lined' : 'G:Lined',
|
||||||
|
'z:lined' : 'Z:Lined',
|
||||||
|
'timeout' : 'Timeout',
|
||||||
|
'closing link' : 'Banned',
|
||||||
|
'banned' : 'Banned',
|
||||||
|
'client exited' : 'QUIT',
|
||||||
|
'quit' : 'QUIT'
|
||||||
|
}
|
||||||
|
|
||||||
def backup(name):
|
def backup(name):
|
||||||
try:
|
try:
|
||||||
with tarfile.open(f'backup/{name}.tar.gz', 'w:gz') as tar:
|
with tarfile.open(f'backup/{name}.tar.gz', 'w:gz') as tar:
|
||||||
@ -253,17 +273,11 @@ class probe:
|
|||||||
del self.channels['users'][chan]
|
del self.channels['users'][chan]
|
||||||
error(f'{self.display}\033[31merror\033[0m - {chan}', badchan[event])
|
error(f'{self.display}\033[31merror\033[0m - {chan}', badchan[event])
|
||||||
elif line.startswith('ERROR :'):
|
elif line.startswith('ERROR :'):
|
||||||
if line.startswith('ERROR :Closing Link'):
|
check = [check for check in badserver if check in line.lower()]
|
||||||
if 'dronebl' in line.lower():
|
if check:
|
||||||
|
if check[0] in ('dronebl','dnsbl'):
|
||||||
self.snapshot['proxy'] = True
|
self.snapshot['proxy'] = True
|
||||||
error(self.display + '\033[93mDroneBL detected\033[0m')
|
raise Exception(badserver[check[0]])
|
||||||
raise Exception('DroneBL')
|
|
||||||
else:
|
|
||||||
raise Exception('Banned')
|
|
||||||
elif line.startswith('ERROR :Trying to reconnect too fast') or line.startswith('ERROR :Your host is trying to (re)connect too fast') or line.startswith('ERROR :Reconnecting too fast'):
|
|
||||||
raise Exception('Throttled')
|
|
||||||
elif line.startswith('ERROR :Access denied'):
|
|
||||||
raise Exception('Access denied')
|
|
||||||
elif args[0] == 'PING':
|
elif args[0] == 'PING':
|
||||||
await self.raw('PONG ' + args[1][1:])
|
await self.raw('PONG ' + args[1][1:])
|
||||||
elif event == '001': #RPL_WELCOME
|
elif event == '001': #RPL_WELCOME
|
||||||
@ -286,7 +300,7 @@ class probe:
|
|||||||
nick = args[3]
|
nick = args[3]
|
||||||
if 'open proxy' in line.lower() or 'proxy monitor' in line.lower():
|
if 'open proxy' in line.lower() or 'proxy monitor' in line.lower():
|
||||||
self.snapshot['proxy'] = True
|
self.snapshot['proxy'] = True
|
||||||
error(self.display + '\033[93mProxy Monitor detected\033[0m')
|
error(self.display + '\033[93mProxy Monitor detected\033[0m', nick)
|
||||||
else:
|
else:
|
||||||
debug(f'{self.display}\033[34mWHOIS\033[0m {nick}')
|
debug(f'{self.display}\033[34mWHOIS\033[0m {nick}')
|
||||||
elif event == '322' and len(args) >= 4: # RPL_LIST
|
elif event == '322' and len(args) >= 4: # RPL_LIST
|
||||||
@ -336,12 +350,11 @@ class probe:
|
|||||||
self.jthrottle = throttle.seconds if seconds > throttle.seconds else seconds
|
self.jthrottle = throttle.seconds if seconds > throttle.seconds else seconds
|
||||||
error(self.display + '\033[31merror\033[0m - delay found', msg)
|
error(self.display + '\033[31merror\033[0m - delay found', msg)
|
||||||
elif event == '465': # ERR_YOUREBANNEDCREEP
|
elif event == '465': # ERR_YOUREBANNEDCREEP
|
||||||
if 'dronebl' in line.lower():
|
check = [check for check in badserver if check in line.lower()]
|
||||||
self.snapshot['proxy'] = True
|
if check:
|
||||||
error(self.display + '\033[93mDroneBL detected\033[0m')
|
if check[0] in ('dronebl','dnsbl'):
|
||||||
raise Exception('DroneBL')
|
self.snapshot['proxy'] = True
|
||||||
else:
|
raise Exception(badserver[check[0]])
|
||||||
raise Exception('K-Lined')
|
|
||||||
elif event == '464': # ERR_PASSWDMISMATCH
|
elif event == '464': # ERR_PASSWDMISMATCH
|
||||||
raise Exception('Network has a password')
|
raise Exception('Network has a password')
|
||||||
elif event == '487': # ERR_MSGSERVICES
|
elif event == '487': # ERR_MSGSERVICES
|
||||||
@ -378,6 +391,9 @@ class probe:
|
|||||||
if msg[:8] == '\001VERSION':
|
if msg[:8] == '\001VERSION':
|
||||||
version = random.choice(('http://www.mibbit.com ajax IRC Client','mIRC v6.35 Khaled Mardam-Bey','xchat 0.24.1 Linux 2.6.27-8-eeepc i686','rZNC Version 1.0 [02/01/11] - Built from ZNC','thelounge v3.0.0 -- https://thelounge.chat/'))
|
version = random.choice(('http://www.mibbit.com ajax IRC Client','mIRC v6.35 Khaled Mardam-Bey','xchat 0.24.1 Linux 2.6.27-8-eeepc i686','rZNC Version 1.0 [02/01/11] - Built from ZNC','thelounge v3.0.0 -- https://thelounge.chat/'))
|
||||||
await self.raw(f'NOTICE {nick} \001VERSION {version}\001')
|
await self.raw(f'NOTICE {nick} \001VERSION {version}\001')
|
||||||
|
elif ('You are connected' in data or 'Connected securely via' in data) and ('SSL' in data or 'TLS' in data):
|
||||||
|
cipher = data.split()[-1:][0].replace('\'','').replace('"','')
|
||||||
|
self.snapshot['ssl_cipher'] = cipher
|
||||||
elif nick == 'NickServ':
|
elif nick == 'NickServ':
|
||||||
self.snapshot['services'] = True
|
self.snapshot['services'] = True
|
||||||
if 'is now registered' in msg or f'Nickname {self.nickname} registered' in msg:
|
if 'is now registered' in msg or f'Nickname {self.nickname} registered' in msg:
|
||||||
@ -389,7 +405,7 @@ class probe:
|
|||||||
error(self.display + '\033[93mDroneBL detected\033[0m')
|
error(self.display + '\033[93mDroneBL detected\033[0m')
|
||||||
raise Exception('DroneBL')
|
raise Exception('DroneBL')
|
||||||
else:
|
else:
|
||||||
if [i for i in ('You\'re banned','You are permanently banned','You are banned','You are not welcome') if i in msg]:
|
if [i for i in ('You\'re banned','You are permanently banned','You are banned','You are not welcome','Temporary K-line') if i in msg]:
|
||||||
raise Exception('K-Lined')
|
raise Exception('K-Lined')
|
||||||
except (UnicodeDecodeError, UnicodeEncodeError):
|
except (UnicodeDecodeError, UnicodeEncodeError):
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user