import socket, hashlib class R: def __init__(s,h,p=8728): s.h=h; s.p=p; s.s=None def c(s,u,p): s.s=socket.socket(); s.s.settimeout(15) s.s.connect((s.h,s.p)) s._ws('/login','=name='+u,'=password='+p) r=s._rr() if any(isinstance(x,tuple) for x in r): for x in r: if isinstance(x,dict) and 'ret' in x: ch=x['ret'] if ch and len(ch)==32: hh=hashlib.md5(b'\x00'+p.encode()+bytes.fromhex(ch)).hexdigest() s._ws('/login','=name='+u,'=response=00'+hh); s._rr() return s def _el(s,l): if l<0x80: return bytes([l]) elif l<0x4000: l|=0x8000; return bytes([(l>>8)&0xFF,l&0xFF]) else: return bytes([0xC0|((l>>16)&0x0F),(l>>8)&0xFF,l&0xFF]) if l<0x200000 else bytes([0xE0|((l>>24)&0x07),(l>>16)&0xFF,(l>>8)&0xFF,l&0xFF]) def _ww(s,w): s.s.sendall(s._el(len(w))+w.encode()) def _ws(s,c,*ws): s._ww(c); [s._ww(w) for w in ws]; s.s.sendall(b'\x00') def _rw(s): f=s.s.recv(1) if f==b'\x00': return None lb=f[0]; l=lb if lb&0x80: if (lb&0xC0)==0x80: l=((lb&0x3F)<<8)+s.s.recv(1)[0] elif (lb&0xE0)==0xC0: l=((lb&0x1F)<<16)+(s.s.recv(1)[0]<<8)+s.s.recv(1)[0] else: l=((lb&0x0F)<<24)+(s.s.recv(1)[0]<<16)+(s.s.recv(1)[0]<<8)+s.s.recv(1)[0] d=b'' while len(d)=3 else '' else: d[w]='' rs.append(d) elif r=='!trap': rs.append(('!trap',t)) return rs def cmd(s,c,**a): ws=[c] for k,v in a.items(): ws.append(('?' if k.startswith('?') else '=')+k+'='+v) s._ws(*ws) return s._rr() def close(s): if s.s: s.s.close() api=R('remote.vpnmurahjogja.my.id',33206).c('mi4','m14') # Check ALL profiles for notification capability print('=== All Profiles with notify ===') for p in api.cmd('/ip/hotspot/user/profile/print'): name = p.get('name','') ol = p.get('on-login','') has_notify = 'notify' in ol or 'telegram' in ol or 'bot' in ol or 'fetch' in ol has_expmode = 'rem' in ol or 'ntf' in ol print(' %s | has_notify=%s | has_expmode=%s' % (name, has_notify, has_expmode)) # Check all schedulers for notify calls print() print('=== Schedulers that call notify ===') for si in api.cmd('/system/scheduler/print'): oe = si.get('on-event','') n = si.get('name','') if 'notify-expire' in oe or 'telegram' in oe or 'fetch' in oe: print(' %s: calls notify-expire' % n) elif 'set limit-uptime' in oe: print(' %s: silent (limit-uptime only)' % n) elif 'remove' in oe: print(' %s: remove only' % n) else: print(' %s: other' % n) # Count how many times per day each notify-scheduler would fire print() print('=== Notification frequency ===') for si in api.cmd('/system/scheduler/print'): n = si.get('name','') intv = si.get('interval','') oe = si.get('on-event','') if 'notify-expire' in oe: # Parse interval parts = intv.split(':') if len(parts) == 3: hrs = int(parts[0]) mins = int(parts[1]) secs = int(parts[2]) total_secs = hrs*3600 + mins*60 + secs if total_secs > 0: per_day = 86400 // total_secs print(' %s: every %s = ~%dx/day per EXPIRED user (NO dedup!)' % (n, intv, per_day)) api.close()