Last active
August 23, 2021 21:08
-
-
Save n0obit4/8d8ef6e5fc5ca2f3c4f26ed2217a2f27 to your computer and use it in GitHub Desktop.
wifran - Ubee model DDW3611 cable modem automated password change | by: N0obit4
This file contains 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 characters
import random | |
class PasswordRandom: | |
def __init__(self): | |
self.abc = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+=' | |
self.iter = 0 | |
def __iter__(self): | |
return self | |
def __next__(self): | |
if self.iter == 13: | |
raise StopIteration | |
char = random.choice(self.abc) | |
self.iter += 1 | |
return char | |
class Pskgen(PasswordRandom): | |
def genpass(self): | |
password = PasswordRandom() | |
passwd = [i for i in password] | |
return "".join(passwd) |
This file contains 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 characters
import requests,time,smtplib,base64 | |
from requests.auth import HTTPBasicAuth | |
from bs4 import BeautifulSoup | |
from email.mime.text import MIMEText | |
from email.mime.multipart import MIMEMultipart | |
from passran import Pskgen as PSK | |
# Author: n0obit4 | |
# Modem: Ubee | |
# Model: DDW3611 | |
class Wifi(): | |
def __init__(self,PSK, | |
user='user', | |
password='user', | |
url='http://192.168.0.1'): | |
self.user = user | |
self.password = password | |
self.url = url | |
self.PSK = PSK | |
self.auth = HTTPBasicAuth(self.user,self.password) | |
self.uri = '/goform/wifiPrimaryNetwork' | |
self.check = self.url+'/wifiPrimaryNetwork.asp' | |
def pwdChange(self,old): | |
data = { | |
"ServiceSetIdentifier":"SSID!", #Change This for your SSID that do you want | |
"ClosedNetwork":0, | |
"ApIsolate":0, | |
"WpaPskAuth":0, | |
"Wpa2PskAuth":1, | |
"WpaEncryption":3, | |
"WpaPreSharedKey":self.PSK, | |
"WpaRekeyInterval":0, | |
"GenerateWepKeys":0, | |
"WepKeysGenerated":0, | |
"commitwlanPrimaryNetwork":1, | |
"AutoSecurity":1 | |
} | |
header = {'Wifran/DDW3611', | |
'Accept':'text/html,application/xhtml+xml,application/xml;' | |
'q=0.9,image/webp,*/*;q=0.8'} | |
request = requests.post(self.url+self.uri, | |
headers=header, | |
auth=self.auth, | |
data=data) | |
if request.status_code == 401: | |
print('Username or Password is wrong') | |
elif request.status_code == 200: | |
print(f'Wifi Password has been changed\n\nThe old Password is: {old}\nThe new Password is: {self.PSK}') | |
return True | |
else: | |
print(request) | |
def pwdCheck(self): | |
request = requests.get(self.check,auth=self.auth) | |
soup = BeautifulSoup(request.text,'html.parser') | |
password = soup.find_all('input') | |
return password[1].get('value') | |
class SendMail(Wifi): | |
def __init__(self,old,new): | |
self.time = [i for i in time.localtime()] | |
self.old = old | |
self.new = new | |
self.sender = 'sender@domain.com' #Your email to send information | |
self.sender_passwd = base64.b64decode(b'RW1haWwgcGFzc3dvcmQ=').decode() #Password encoded to base64 | |
self.receiver = ['receiver1@domain.com','receiver2@domain.com'] #Destination address | |
self.smtp = smtplib.SMTP('smtp.gmail.com',587) #SMTP information | |
def make_msj(self): | |
if len(str(self.time[3])) == 1: | |
hour = '0'+str(self.time[3]) | |
else: | |
hour = self.time[3] | |
if len(str(self.time[4])) == 1: | |
minuts = '0'+str(self.time[4]) | |
else: | |
minuts = self.time[4] | |
if len(str(self.time[5])) == 1: | |
seg = '0'+str(self.time[5]) | |
else: | |
seg = self.time[5] | |
msg = MIMEMultipart() | |
msg['Subject'] = 'Wifi Password Changed' | |
text = f'''<center> | |
<h1 style='color:black';>The Wifi Password have been changed</h1><br> | |
</center> | |
<div style="background-color:#EEEEEE;font-size: 20px;height: 50;position: absolute;padding: 1%;right: 50%;"> | |
<h3><pre> Detalles</pre></h3> | |
<ul> | |
<li><b>Date:</b> {self.time[2]}/{self.time[1]}/{self.time[0]}<br></li> | |
<li><b>Hour:</b> {hour}:{minuts}:{seg}<br></li> | |
<li><b>Old:</b> {self.old}<br></li> | |
<li><b>New:</b> {self.new}<br></li> | |
</ul> | |
</div> | |
''' | |
msj = MIMEText(text,'html') | |
msg.attach(msj) | |
return msg | |
def send(self,mensaje): | |
self.smtp.ehlo() | |
self.smtp.starttls() | |
self.smtp.ehlo() | |
self.smtp.login(self.sender,self.sender_passwd) | |
self.smtp.sendmail(self.sender,self.receiver,mensaje.as_string()) | |
self.smtp.quit() | |
print('Email have benn Sent') | |
if __name__ == '__main__': | |
password = PSK() | |
psk = password.genpass() | |
wifi = Wifi(PSK=psk,url='http://172.16.20.254') #Change ip address | |
chk = wifi.pwdCheck() | |
Email = SendMail(chk,psk) #Remove this line if you dont use email | |
Email.send(Email.make_msj()) #Remove this line if you dont use email | |
wifi.pwdChange(chk) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wifran - Ubee model DDW3611
Automated wireless information change
Wifran send report via email and save a local file.
Requeriments to run
You need pip3 to install this packages.