#!/bin/sh # by pizza # when i ssh in remotely, neither lynx, links nor w3m can handle the fucking pointless javascript # the WRT54G uses in its web forms, so here's a fucking script to do it with curl. argh! # NOTE: this will simply overwrite anything you have in there currently, so be fucking careful wrt54g_ip="192.168.1.1" user="admin" echo -n "password: " stty -echo read pass stty echo if [ "$pass" = "" ]; then echo "" echo "no password, quitting" exit fi #name[#]="just a name for your own purposes, keep it short" # from[#]="begin port range" # to[#]="end port range" # pro[#]="tcp","udp" or "both" # ip[#]="last ip octet", i.e. "100" -> "192.168.1.100" # enable[#]="on" or "" name0="svnserve" from0="3690" to0="3690" pro0="tcp" ip0="102" enable0="on" name1="sshd" from1="22" to1="22" pro1="tcp" ip1="100" enable1="on" name2="sshd2" from2="2222" to2="2222" pro2="tcp" ip2="102" enable2="on" name3="http" from3="8081" to3="8081" pro3="tcp" ip3="100" enable3="on" name4="identd" from4="113" to4="113" pro4="tcp" ip4="100" enable4="on" name5="" from5="" to5="" pro5="tcp" ip5="" enable5="" name6="" from6="" to6="" pro6="tcp" ip6="" enable6="" name7="" from7="" to7="" pro7="tcp" ip7="" enable7="" name8="" from8="" to8="" pro8="tcp" ip8="" enable8="" name9="" from9="" to9="" pro9="tcp" ip9="" enable9="" curl -v \ --form "submit_button=Forward;action=Apply;forward_port=10;name0=$name0;to0=$to0;from0=$from0;pro0=$pro0;ip0=$ip0;enable0=$enable0;name1=$name1;to1=$to1;from1=$from1;pro1=$pro1;ip1=$ip1;enable1=$enable1;name2=$name2;to2=$to2;from2=$from2;pro2=$pro2;ip2=$ip2;enable2=$enable2;name3=$name3;to3=$to3;from3=$from3;pro3=$pro3;ip3=$ip3;enable3=$enable3;name4=$name4;to4=$to4;from4=$from4;pro4=$pro4;ip4=$ip4;enable4=$enable4;name5=$name5;to5=$to5;from5=$from5;pro5=$pro5;ip5=$ip5;enable5=$enable5;name6=$name6;to6=$to6;from6=$from6;pro6=$pro6;ip6=$ip6;enable6=$enable6;name7=$name7;to7=$to7;from7=$from7;pro7=$pro7;ip7=$ip7;enable7=$enable7;name8=$name8;to8=$to8;from8=$from8;pro8=$pro8;ip8=$ip8;enable8=$enable8;name9=$name9;to9=$to9;from9=$from9;pro9=$pro9;ip9=$ip9;enable9=$enable9;" \ --referer http://192.168.1.1/Forward.asp \ --user $user:$pass \ http://$wrt54g_ip/apply.cgi