This thread is a place to post your reconnection scripts that are useful with JDownloader. If the script is not for reconnection, post it here. Do not post Liveheader/Curl scripts here (post those in the thread for that router).
Examples of useful scripts would be changing the MAC address of a local computer, reconnecting without a router, D-Link scripts, UPNP scripts, and so on.
You must explain what the script is for and how to use it.
Please remember to post any requirements (OS, interpreter, and so on).
If the script is long, put it in a Spoiler (Go Advanced).
Disclaimer: These scripts are not tested by JD staff, but other members have posted the scripts here for your use. There is no guarantee that the script will work for you. JDownloader.org takes no responsibility for any damage that might be caused by running a script.
Hey JDownloader users, I noticed J doesn't have a reconnect script for D-link DSL2640U router, so i recorded mine, you can use it, Password and username is admin(default)
Here goes the script:
Spoiler:
Code:
[[[HSRC]]]
[[[STEP]]]
[[[REQUEST]]]
GET / HTTP/1.1
Host: %%%routerip%%%
[[[/REQUEST]]]
[[[/STEP]]]
[[[STEP]]]
[[[REQUEST]]]
GET /menu.html HTTP/1.1
Host: %%%routerip%%%
[[[/REQUEST]]]
[[[/STEP]]]
[[[STEP]]]
[[[REQUEST]]]
GET /homehelp.html HTTP/1.1
Host: %%%routerip%%%
[[[/REQUEST]]]
[[[/STEP]]]
[[[STEP]]]
[[[REQUEST]]]
GET /updatesettings.html HTTP/1.1
Host: %%%routerip%%%
[[[/REQUEST]]]
[[[/STEP]]]
[[[STEP]]]
[[[REQUEST]]]
GET /util.js HTTP/1.1
Host: %%%routerip%%%
[[[/REQUEST]]]
[[[/STEP]]]
[[[STEP]]]
[[[REQUEST]]]
GET /menu.html HTTP/1.1
Host: %%%routerip%%%
[[[/REQUEST]]]
[[[/STEP]]]
[[[STEP]]]
[[[REQUEST]]]
GET /mainhelp.html HTTP/1.1
Host: %%%routerip%%%
[[[/REQUEST]]]
[[[/STEP]]]
[[[STEP]]]
[[[REQUEST]]]
GET /rebootinfo.cgi HTTP/1.1
Host: %%%routerip%%%
[[[/REQUEST]]]
[[[/STEP]]]
[[[/HSRC]]]
Moderator Edit: The script in the Wiki did not work for this user.
-----------------------------------------------------------------
I scripted one on my own (This was quite tricky, since I had to transfer lots of java-script-functions the router uses to compute the login hash...).
What I did was, I wrote a bash-script (sorry Windows-guys, Unix-only...) to do basic connecting/ disconnecting/ reconnecting with the router.
Only problem: The login-hash.
To compute this I wrote a java-program that computes the hash from the random number the router sends and the password.
bash-script:
Spoiler:
Code:
#!/bin/bash
#begin options
declare nonsilent
nonsilent=true
declare no_ignore_failed
no_ignore_failed=true
declare timeout
timeout=60
declare pass
pass=""
declare javadir
javadir="${HOME}/java/"
#end options
#begin global variables
declare action
action=""
declare newip
newip=""
declare exitcode
exitcode=0
#end global variables
#begin helper functions
function echo {
if ${nonsilent} ; then
builtin echo "$@"
fi
}
function enable_login {
data=`lynx -dump **External links are only visible to Support Staff** data=${data:9:8}
wd=$(pwd)
cd ${javadir}
code=$(java prepare_login "${data}" "${pass}")
cd ${wd}
response=$(lynx -dump "**External links are only visible to Support Staff**)
if [ "${response:3}" == "ERROR" ]; then
echo "Login refused (wrong password?)"
exitcode=$((${exitcode}|16))
if ${no_ignore_failed} ; then
echo "Exit."
exit ${exitcode}
else
echo "Trying to proceed anyway."
fi
fi
# lynx -dump **External links are only visible to Support Staff**}
function connect {
echo "Connecting..."
lynx -dump **External links are only visible to Support Staff** echo "Connection Requested. Waiting..."
echo "" > .TEMPNEWIP
lynx -dump "**External links are only visible to Support Staff** > .TEMPNEWIP &
lynxpid=$!
declare success
success=false
for ((i=0; i<${timeout}; i++)) do
if [ -n "$(cat .TEMPNEWIP)" ]; then
success=true
newip=$(cat .TEMPNEWIP)
rm .TEMPNEWIP
break
fi
sleep 1
done
if [ -z "${newip}" ]; then
echo "Connection failed. Consider manual reconnection (or wait some longer)."
kill ${lynxpid} > /dev/null
rm .TEMPNEWIP
exitcode=$((${exitcode}|4))
else
echo "Done."
echo "New IP: ${newip}"
exitcode=$((${exitcode}|1))
fi
}
function disconnect {
echo "Disconnecting..."
lynx -dump **External links are only visible to Support Staff** echo "Done."
exitcode=$((${exitcode}|2))
}
function reconnect {
oldip=$(lynx -dump "**External links are only visible to Support Staff**)
echo "Attempting reconnect..."
echo "Old IP was: ${oldip}"
echo ""
disconnect
echo ""
sleep 1
connect
if [ -n "${newip}" ]; then
if [ "${oldip}" == "${newip}" ]; then
echo "New IP equals old one (probably static IP)."
exitcode=$((${exitcode}|8))
else
echo "New IP is different from old one."
fi
fi
}
#end helper functions
#begin script
case ${1} in
connect|disconnect|reconnect)
action=${1}
pass=${2}
if [ -n "${3}" ]; then
shift
shift
while [ -n "${1}" ]; do
case ${param} in
-t|--timeout)
shift
timeout=${1}
shift
;;
-s|--silent)
nonsilent=false
;;
-i|--ignore-failed)
no_ignore_failed=false
shift
;;
-j|--java-dir)
shift
javadir=${1}
shift
;;
*)
exitcode=$((${exitcode}|128))
echo "Ignored unknown option: ${1}"
shift
;;
esac
done
fi
enable_login
;;
*)
echo "Usage:"
echo "routerctrl.sh (connect|disconnect|reconnect) <pass> [OPTIONS]"
echo ""
echo "Valid options are:"
echo " -t|--timeout <timeout> Specifies timeout in seconds for connect (default: 60)"
echo " -s|--silent Silent"
echo " -i|--ignore-failed Tries to proceed with further steps even if login is refused"
echo " -j|--java-dir <dir> Specify directory of prepare_login.class"
echo ""
echo "Exitcodes (or'd):"
echo " 0: nothing"
echo " 1: successfully connected"
echo " 2: successfully disconnected"
echo " 4: connecting failed"
echo " 8: reconnected successfully, but new IP equals old one"
echo " 16: login refused"
echo " 128: one or more unknown options specified"
echo ""
echo "Written by Entropy"
exit 0
esac
${action}
exit ${exitcode}
#end script
Java-code:
Spoiler:
Code:
// Written by Entropy
class prepare_login {
static private int[] b64_char_to_6;
static private String pwd;
prepare_login() {
}
//Build a 256 entry array that convert a base-64 character to its corresponding 6-bit number. Invalid characters will be translated to 0.
static private void build_b64_char_to_6() {
b64_char_to_6 = new int[256];
for (int i=0; i<256; ++i) b64_char_to_6[i] = 0;
for (int i=0; i<26; ++i) b64_char_to_6[i+65] = i+1;
for (int i=0; i<26; ++i) b64_char_to_6[i+97] = i+27;
for (int i=0; i<10; ++i) b64_char_to_6[i+48] = i+53;
b64_char_to_6[95] = 63;
}
static private void from_base64(String buf, int[] dst) {
byte j = 0;
for (int i = 0; i < buf.length(); i += 4) {
int cc_1 = (b64_char_to_6[(int)buf.charAt(i)] << 18);
int cc_2 = (b64_char_to_6[(int)buf.charAt(i+1)] << 12);
int cc_3 = (b64_char_to_6[(int)buf.charAt(i+2)] << 6);
int cc_4 = (b64_char_to_6[(int)buf.charAt(i+3)]);
int cc = cc_1 | cc_2 | cc_3 | cc_4;
dst[j] = (cc >> 16) & 0xff;
dst[j+1] = (cc >> 8) & 0xff;
dst[j+2] = (cc) & 0xff;
j += 3;
}
}
static private String maketwochar(String s) {
if (s.length()<2) s="0"+s;
return s;
}
static private String fillstr(String s, byte l) {
while (s.length()<l) {
s = s + (char)1;
}
return s;
}
static private String to_HexString(int[] dst) {
String s = "";
for (byte i=0; i<4; ++i) {
s = s + maketwochar(Integer.toHexString(dst[i]));
}
return s.toUpperCase();
}
// Convert a string to an array of little-endian words
static private void str2binl(String s, int[] bin) {
byte mask = (byte)((1 << 8) - 1);
for(int i=0; i<s.length()*8; i+=8) {
bin[i>>5] |= ((byte)s.charAt(i/8) & mask) << (i%32);
}
}
// Bitwise rotate a 32-bit number to the left.
static private int bit_rol(int num, int cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}
// Some obscure adding algorithm the router uses
static private int safe_add(int x, int y) {
int lsw = (x & 0xFFFF) + (y & 0xFFFF);
int msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
// Begin basic md5 algorithms
static private int md5_cmn(int q, int a, int b, int x, int s, int t) {
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
static private int md5_ff(int a, int b, int c, int d, int x, int s, int t) {
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
static private int md5_gg(int a, int b, int c, int d, int x, int s, int t) {
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
static private int md5_hh(int a, int b, int c, int d, int x, int s, int t) {
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
static private int md5_ii(int a, int b, int c, int d, int x, int s, int t) {
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
// End basic md5 algorithms
// Core md5algorithm
static public void core_md5(int[] x, int len, int[] md5_arr) {
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
int a = 1732584193;
int b = -271733879;
int c = -1732584194;
int d = 271733878;
for (int i = 0; i < x.length; i+=16) {
int olda = a;
int oldb = b;
int oldc = c;
int oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
md5_arr[0] = a;
md5_arr[1] = b;
md5_arr[2] = c;
md5_arr[3] = d;
}
static private String binl2hex(int[] binarray) {
String hex_tab = "0123456789abcdef";
String str = "";
for (int i = 0; i < binarray.length*4; ++i) {
str = str + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8)) & 0xF);
}
return str;
}
static private String hex_md5(String s) {
int[] bin;
bin = new int[32];
int[] md5_arr;
md5_arr = new int[4];
str2binl(s, bin);
core_md5(bin, s.length()*8, md5_arr);
return binl2hex(md5_arr);
}
// Convert a hex string of 'len' bytes into a byte array of 'len2' bytes. Ignore leading and trailing whitespace. If there are any conversion errors or the string is the wrong length or the string is empty or all whitespace, return an array of all zeros.
// Since here input is guaranteed to be a pure hex string, we ignore all the case-checking the router-script does...
static private void convertHexString(String s, int len, int len2, short[] a) {
int i;
for (i=0; i < len; ++i) {
a[i] = (short)Integer.parseInt(s.substring(i*2,i*2+2),16);
}
for (; i < len2; ++i) {
a[i] = (short)0;
}
}
static private String convertToBase64(short[] arr) {
// Make array with k*4 entries
short[] a;
int templen = arr.length;
while ( (templen%3) != 0 ) {
++templen;
}
a = new short[templen];
int i;
for (i = 0; i < arr.length; ++i) {
a[i] = arr[i];
}
for (; i < templen; ++i) {
a[i] = (short)0;
}
String b64 = ".ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
String str = "";
for (i=0; i < a.length; i += 3) {
int x = (a[i] << 16) | (a[i+1] << 8) | a[i+2];
str = str + b64.charAt((x >> 18) & 0x3f) + b64.charAt((x >> 12) & 0x3f) + b64.charAt((x >> 6) & 0x3f) + b64.charAt(x & 0x3f);
}
return str;
}
static public void main(String[] args){
String buf;
int[] dst;
String str;
String shex;
String hash;
String saltHash;
short[] bytearr;
buf = args[0];
pwd = args[1];
while ( (buf.length()%4) != 0 ) { // Make buf.length() divisible by 4
buf = buf + ".";
}
dst = new int[buf.length()];
build_b64_char_to_6();
from_base64(buf, dst);
shex = to_HexString(dst);
pwd = fillstr(pwd, (byte)16);
str = shex + pwd;
str = fillstr(str, (byte)64);
hash = hex_md5(str);
saltHash = shex+hash;
bytearr = new short[20];
convertHexString(saltHash, 20, 20, bytearr);
System.out.println(convertToBase64(bytearr));
}
}
The script awaits the first parameter to be "reconnect" (which is what you want it to do for jDownloader) and the second one to be your password. (First line in the jDownloader-option-tab for the script is "reconnect", second one your password)
Additionally, the it expects the java program to be named prepare_login.class and to be at ${HOME}/java/; the path can be changed by the parameter "-j <dir>" (one line in jDownloader-option-tab for the script is "-j", the next one the directory where you stored the class).
(To compile the java-file simply safe it as prepare_login.java and enter "java prepare_login" to your console)
I hope I am able to help all those who experienced the same annoyance with this router as I did
Feel free to use and spread these as long as you don't remove the "Written by"s
This has to be run as an administrator. Netsh is slow, so all enough time in the reconnection timeout (30 seconds is plenty).
This also serves as an example for rotating through multiple proxies, NICs, MAC addresses, or other lists
The list of values can also be stored in an environment variable instead of files. In that approach, if the variable is empty or missing, it is set up with a string of space separated values. If %1 is empty, call the script recursively with the expanded variable as a parameter. Now %1 is like %V below. Before exiting, use SHIFT to remove %1 from the variable and then reassign the variable with %*.
Code:
setlocal
REM Replace the next line with the correct directory.
cd /d c:\programs\jdownloader
REM Change DSL below to the name of your connection (shown by ipconfig.exe).
REM Mine shows "Ethernet Adapter: DSL"
set adapter=DSL
REM Change 255.255.255.0 below to the subnet mask shown by ipconfig.exe
set mask=255.255.255.0
if not exist iplist\* mkdir iplist
cd iplist
if not exist *.ip (
REM Change the following to your IP addresses.
echo "not used yet" > 192.168.1.15.ip
echo "not used yet" > 192.168.1.16.ip
)
for %%V in (*.ip) do (
echo %%~nV
set NewIP=%%~nV
goto :have_IP
)
:have_IP
del %NewIP%.ip
REM Be patient, the next line is very slow.
netsh interface ip set address %adapter% static %NewIP% %mask%
endlocal
In new Tomato versions, the HTML page contains a dynamically generated ID that has to be submitted together with the POST, in order to avoid cross site scripting vulnerability.
The above script first downloads the main page, and extracts the "secret" ID (tid). Then stops the wan service, sleeps 2 seconds, restarts the wan-service and at the end sleeps other 5 seconds.
I tested it and it works flawless on my WRT54GL router.
Could you add the script to the knowledge/wiki page?
Hey there.
a few months ago i posted a script in a new thread, but now you made an sticky with userscripts ^^
This Script is tested with Fritz!Box FON WLAN 7270 & 7390
Code:
[[[HSRC]]]
[[[STEP]]]
[[[REQUEST]]]
POST /upnp/control/WANIPConn1 HTTP/1.1
Host: %%%routerip%%%:49000
Content-Type: text/xml; charset="utf-8"
SoapAction:urn:schemas-upnp-org:service:WANIPConnection:1#ForceTermination
<?xml version='1.0' encoding='utf-8'?> <s:Envelope s:encodingStyle='**External links are only visible to Support Staff** xmlns:s='**External links are only visible to Support Staff**> <s:Body> <u:ForceTermination xmlns:u='urn:schemas-upnp-org:service:WANIPConnection:1' /> </s:Body> </s:Envelope>
[[[/REQUEST]]]
[[[/STEP]]]
[[[/HSRC]]]
P.S.: the fastest Fritz!Box Reconnect Script i know!
Hello!
This is my self-made reconnecter for thomson tg585 v7 router.
Spoiler:
It's not really a script, but it's an executable for windows.
Download it here:
**External links are only visible to Support Staff****External links are only visible to Support Staff**
http:-//jsw.netau.net/downloads/?file=reconnect (remove the minus after http: )
Hey there.
a few months ago i posted a script in a new thread, but now you made an sticky with userscripts ^^
This Script is tested with Fritz!Box FON WLAN 7270 & 7390
Code:
[[[HSRC]]]
[[[STEP]]]
[[[REQUEST]]]
POST /upnp/control/WANIPConn1 HTTP/1.1
Host: %%%routerip%%%:49000
Content-Type: text/xml; charset="utf-8"
SoapAction:urn:schemas-upnp-org:service:WANIPConnection:1#ForceTermination
<?xml version='1.0' encoding='utf-8'?> <s:Envelope s:encodingStyle='**External links are only visible to Support Staff** xmlns:s='**External links are only visible to Support Staff**> <s:Body> <u:ForceTermination xmlns:u='urn:schemas-upnp-org:service:WANIPConnection:1' /> </s:Body> </s:Envelope>
[[[/REQUEST]]]
[[[/STEP]]]
[[[/HSRC]]]
P.S.: the fastest Fritz!Box Reconnect Script i know!
Funktioniert auch super mit der Fritz Box 7330 SL (W-Lan)!!!
Well, I did not found any reconnect script for the FrritzBox 7390 which does NOT utilize uPnP. So I wrote one by myself.
For everyone out there who does not understand why I did this: It is a fact that uPnP could be a security risk. If you use uPnP to configre yor router/nat/firewall it usually is a security risk.
This script is a Powershell script. (Well, Powershell is a command prompt written by Microsoft. On Windows 7 it is installed by default.)
Installation instructions coud be found in the script.
The file extension for powershell scripts is "ps1". So you may put the following script into a file called "reconnect.ps1".
Spoiler:
Code:
# -------------------------------------------------------------------------- #
# PS reconnect Script for FritzBox 7390 #
# by Axel1492 #
# #
# This Script is for everyone who does not want to enable UPnP on his #
# FritzBox. This Script reproduces the Javascript based challenge-response #
# protocol of the web interface. #
# #
# PREPARATION: You need to allow the excecution of Powershell scripts on #
# your PC. You could easily do this by running the folloowing #
# command in an admin priviledged Powershell promt: #
# Set-ExecutionPolicy RemoteSigned #
# If you want some information about what you are doing run: #
# Get-Help About_Signing #
# #
# Call from JD: Use the 'External' configuration. Enter as 'Command': #
# %windir%\System32\WindowsPowerShell\v1.0\powershell.exe #
# As 'Parameter' enter the path to this script. #
# -------------------------------------------------------------------------- #
# -------------------------------------------------------------------------- #
# Just Enter your Password below and enjoy ;-) #
# -------------------------------------------------------------------------- #
[string]$_host_ = "**External links are only visible to Support Staff**
[string]$_pass_ = "******"
# -------------------------------------------------------------------------- #
# internal stuff #
# -------------------------------------------------------------------------- #
# these values are queried from the server or they are computed
[string]$challenge = [string].Empty
[string]$challenge_response = [string].Empty
[string]$sid = "0000000000000000"
# send a Post-message to the server and get the response
Function Post ( [string]$path, [string]$req )
{
[System.Text.Encoding]$encASCII = New-Object System.Text.ASCIIEncoding
$webRequest = [System.Net.WebRequest]::Create($_host_+$path)
$reqBytes = $encASCII.GetBytes($req)
$webRequest.Method = "Post"
$webRequest.ContentLength = $reqBytes.Length
$webRequest.ContentType = "application/x-www-form-urlencoded"
$stream = $webRequest.GetRequestStream()
$stream.Write($reqBytes,0,$reqBytes.Length)
$stream.close()
[System.Net.HttpWebResponse]$resp = $webRequest.GetResponse()
$rs = $resp.GetResponseStream()
$sr = New-Object System.IO.StreamReader -argumentList $rs
$results = $sr.ReadToEnd()
$sr.Close()
$resp.close()
return $results
}
# compute the challenge-response
Function Chall-Resp ( $challenge )
{
[System.Text.Encoding]$encUnicode = New-Object System.Text.UnicodeEncoding
[System.Security.Cryptography.MD5]$hasher = [System.Security.Cryptography.MD5]::Create()
$_pass_ = [System.Text.RegularExpressions.Regex]::Replace($_pass_, "[^\u0000-\u007F]", ".");
$bytes = $hasher.ComputeHash($encUnicode.GetBytes($challenge+"-"+$_pass_))
[string]$hex = [String].Empty
foreach ($b in $bytes) {
$hex += "{0:x2}" -f $b
}
return $challenge+"-"+$hex
}
# -------------------------------------------------------------------------- #
# the interesting part #
# -------------------------------------------------------------------------- #
# query challenge
$challenge = ([xml] (Post "cgi-bin/webcm" "getpage=../html/login_sid.xml")).SessionInfo.Challenge
# compute challenge-response
$challenge_response = Chall-Resp $challenge
# login
$sid = ([xml] (Post "cgi-bin/webcm" "login:command/response=$($challenge_response)&getpage=../html/login_sid.xml")).SessionInfo.SID
if ( $sid.equals("0000000000000000") )
{
"`n`t+++ Login Failed! +++`n"
Exit
}
# disconnect FritzBox from internet (reconnects automatically)
Post "cgi-bin/webcm" "sid=$($sid)&connection0:settings/cmd_disconnect=" | Out-Null
"`n`tSuccessfully initiated reconnect!`n"
# logout
Post "cgi-bin/webcm" "sid=$($sid)&security:command/logout=" | Out-Null
Well, I did not found any reconnect script for the FrritzBox 7390 which does NOT utilize uPnP. So I wrote one by myself.
For everyone out there who does not understand why I did this: It is a fact that uPnP could be a security risk. If you use uPnP to configre yor router/nat/firewall it usually is a security risk.
This script is a Powershell script. (Well, Powershell is a command prompt written by Microsoft. On Windows 7 it is installed by default.)
Installation instructions coud be found in the script.
The file extension for powershell scripts is "ps1". So you may put the following script into a file called "reconnect.ps1".
Spoiler:
Code:
# -------------------------------------------------------------------------- #
# PS reconnect Script for FritzBox 7390 #
# by Axel1492 #
# #
# This Script is for everyone who does not want to enable UPnP on his #
# FritzBox. This Script reproduces the Javascript based challenge-response #
# protocol of the web interface. #
# #
# PREPARATION: You need to allow the excecution of Powershell scripts on #
# your PC. You could easily do this by running the folloowing #
# command in an admin priviledged Powershell promt: #
# Set-ExecutionPolicy RemoteSigned #
# If you want some information about what you are doing run: #
# Get-Help About_Signing #
# #
# Call from JD: Use the 'External' configuration. Enter as 'Command': #
# %windir%\System32\WindowsPowerShell\v1.0\powershell.exe #
# As 'Parameter' enter the path to this script. #
# -------------------------------------------------------------------------- #
# -------------------------------------------------------------------------- #
# Just Enter your Password below and enjoy ;-) #
# -------------------------------------------------------------------------- #
[string]$_host_ = "**External links are only visible to Support Staff**
[string]$_pass_ = "******"
# -------------------------------------------------------------------------- #
# internal stuff #
# -------------------------------------------------------------------------- #
# these values are queried from the server or they are computed
[string]$challenge = [string].Empty
[string]$challenge_response = [string].Empty
[string]$sid = "0000000000000000"
# send a Post-message to the server and get the response
Function Post ( [string]$path, [string]$req )
{
[System.Text.Encoding]$encASCII = New-Object System.Text.ASCIIEncoding
$webRequest = [System.Net.WebRequest]::Create($_host_+$path)
$reqBytes = $encASCII.GetBytes($req)
$webRequest.Method = "Post"
$webRequest.ContentLength = $reqBytes.Length
$webRequest.ContentType = "application/x-www-form-urlencoded"
$stream = $webRequest.GetRequestStream()
$stream.Write($reqBytes,0,$reqBytes.Length)
$stream.close()
[System.Net.HttpWebResponse]$resp = $webRequest.GetResponse()
$rs = $resp.GetResponseStream()
$sr = New-Object System.IO.StreamReader -argumentList $rs
$results = $sr.ReadToEnd()
$sr.Close()
$resp.close()
return $results
}
# compute the challenge-response
Function Chall-Resp ( $challenge )
{
[System.Text.Encoding]$encUnicode = New-Object System.Text.UnicodeEncoding
[System.Security.Cryptography.MD5]$hasher = [System.Security.Cryptography.MD5]::Create()
$_pass_ = [System.Text.RegularExpressions.Regex]::Replace($_pass_, "[^\u0000-\u007F]", ".");
$bytes = $hasher.ComputeHash($encUnicode.GetBytes($challenge+"-"+$_pass_))
[string]$hex = [String].Empty
foreach ($b in $bytes) {
$hex += "{0:x2}" -f $b
}
return $challenge+"-"+$hex
}
# -------------------------------------------------------------------------- #
# the interesting part #
# -------------------------------------------------------------------------- #
# query challenge
$challenge = ([xml] (Post "cgi-bin/webcm" "getpage=../html/login_sid.xml")).SessionInfo.Challenge
# compute challenge-response
$challenge_response = Chall-Resp $challenge
# login
$sid = ([xml] (Post "cgi-bin/webcm" "login:command/response=$($challenge_response)&getpage=../html/login_sid.xml")).SessionInfo.SID
if ( $sid.equals("0000000000000000") )
{
"`n`t+++ Login Failed! +++`n"
Exit
}
# disconnect FritzBox from internet (reconnects automatically)
Post "cgi-bin/webcm" "sid=$($sid)&connection0:settings/cmd_disconnect=" | Out-Null
"`n`tSuccessfully initiated reconnect!`n"
# logout
Post "cgi-bin/webcm" "sid=$($sid)&security:command/logout=" | Out-Null
Hey Axel1492,
Can´t allow the excecution of Powershell scripts by "Set-ExecutionPolicy RemoteSigned". --> Zugriff verweigert. Bei Zeile 1 Zeichen 20 - Not Specified: Set-ExecutionPolicy, UnauthoriziedAccessException
Can´t allow the excecution of Powershell scripts by "Set-ExecutionPolicy RemoteSigned". --> Zugriff verweigert. Bei Zeile 1 Zeichen 20 - Not Specified: Set-ExecutionPolicy, UnauthoriziedAccessException
Yes, execution of unsigned powershell scripts is now disabled by default, and for good reasons. If you're feeling lucky, you could go into powershell and do a
Code:
Set-ExecutionPolicy Unrestricted
which will stick unless overridden by group policies.
Precisely what I've been using with a Fritz! 2170. Perfect and far superior to what jd's wizards have to offer for the series (those work, but perform an atm-level line reset AFAIK, which takes a few minutes). I do not trust upnp either, but since this works with the most restrictive upnp-related router settings, there's no reason not to use it.
Quote:
Originally Posted by usagi-sama
This Script is tested with Fritz!Box FON WLAN 7270 & 7390
Code:
[[[HSRC]]]
[[[STEP]]]
[[[REQUEST]]]
POST /upnp/control/WANIPConn1 HTTP/1.1
Host: %%%routerip%%%:49000
Content-Type: text/xml; charset="utf-8"
SoapAction:urn:schemas-upnp-org:service:WANIPConnection:1#ForceTermination
<?xml version='1.0' encoding='utf-8'?> <s:Envelope s:encodingStyle='**External links are only visible to Support Staff** xmlns:s='**External links are only visible to Support Staff**> <s:Body> <u:ForceTermination xmlns:u='urn:schemas-upnp-org:service:WANIPConnection:1' /> </s:Body> </s:Envelope>
[[[/REQUEST]]]
[[[/STEP]]]
[[[/HSRC]]]
this is a working reconnection script for the Speedtouch 706 (6.2.29.2).
I got it from an existing script for an earlier Speedtouch model, which was here on the wiki,
simply replacing the name and the line starting with POST
Keep in mind that you have to fill in the fields username (Administrator), password, and router IP (192.168.1.254) in the gui.
Habe nach langer suche im Forum, dieses Script für das THOMSON TG585 v7 SW:8.2.1.5 unter Windows7 zum laufen gebracht, da der Reconnect nach Update des JDownloader auf die aktuelle Version mit der TST10.exe nicht mehr möglich war.
[[[HSRC]]]
[[[STEP]]]
[[[REQUEST]]]
GET / HTTP/1.1
Host: %%%routerip%%%
[[[/REQUEST]]]
[[[/STEP]]]
[[[STEP]]]
[[[REQUEST]]]
GET /util.js HTTP/1.1
Host: %%%routerip%%%
[[[/REQUEST]]]
[[[/STEP]]]
[[[STEP]]]
[[[REQUEST]]]
GET /b_menu.js HTTP/1.1
Host: %%%routerip%%%
[[[/REQUEST]]]
[[[/STEP]]]
[[[STEP]]]
[[[REQUEST]]]
POST /?be=0&l0=-1&l1=-1 HTTP/1.1
Host: %%%routerip%%%
hi there!! I wroted this script and posted it in ubuntu help forum. It should work on every linux/unix system i think with a ppp based internet connection (think it is said like this) Works via telnet generally on those systems.
This is muy guide for ubuntu/debian users.
First of all, script is written in bash expect (think is like that)we have to install the expect lib via synaptic or terminal
Code:
sudo apt-get install expect
We create the .sh file and put it in home/"user"/JDownloader/ i do it like that:
Code:
sudo gedit /home/"user"/JDownloader/reconnect.sh
and paste the text above as it is but changing your own data
here's my nifty lil cable reconnection script (python3).
it will assign a new mac address to the router and thus force the cable modem to request a new ip.
it should be easy to customize it for different hardware.
you will need python3 to run this.
**External links are only visible to Support Staff**DOWNLOAD