Skip to content

Commit

Permalink
correction script
Browse files Browse the repository at this point in the history
update pw.cgi
update run.sh
update main.js
  • Loading branch information
gplayec committed Jun 15, 2024
1 parent 48d8922 commit 88e157c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 36 deletions.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ if [ -d /tmp/PPPwn_ow-main ]; then
rm -r /tmp/PPPwn_ow-main
fi

chmod +x /etc/init.d/pppoe-server
chmod +x /www/cgi-bin/pw.cgi
chmod +x /root/run.sh

if ! grep -q "list device 'ppp+'" /etc/config/firewall; then
sed -i "s/option name 'lan'/option name 'lan'\n\t list device 'ppp+'/" /etc/config/firewall
Expand Down
15 changes: 5 additions & 10 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#!/bin/sh

interface=""
version=""
root="/root"
timeout=0
stage1=""
stage2=""
source /root/pw.conf

if /etc/init.d/pppoe-server status | grep -q "running"; then
/etc/init.d/pppoe-server stop
Expand All @@ -15,15 +10,15 @@ ip link set $interface down
sleep 5
ip link set $interface up

pppwn --interface "$interface" --fw "$version" --stage1 $stage1 --stage2 $stage2 --timeout $timeout --auto-retry
res=$(pppwn --interface "$interface" --fw "$version" --stage1 "$stage1" --stage2 "$stage2" --timeout $timeout --auto-retry)

if [ $? -eq 0 ]; then
if [ $res -eq 0 ]; then
if /etc/init.d/pppoe-server status | grep -q "inactive"; then
/etc/init.d/pppoe-server start
fi
echo "Console attempts($attempts) PPPwned!\n" > "log"
echo "$res" > "log"
exit 0
else
echo "Fail attempts($attempts)\n" > "log"
echo "$res" > "log"
exit 1
fi
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1
0.1.6
65 changes: 41 additions & 24 deletions www/cgi-bin/pw.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ if [ "$token" = "token_id" ]; then
echo "},"
if [ -f /root/pw.conf ];then
source /root/pw.conf
echo "\"adapter\":\"$inputAdapter\","
echo "\"timeout\":\"$inputTimeout\","
echo "\"version\":\"$inputVersion\","
echo "\"adapter\":\"$interface\","
echo "\"timeout\":\"$timeout\","
echo "\"version\":\"$version\","
fi
else
echo "\"pppwn\":false,"
Expand Down Expand Up @@ -181,13 +181,13 @@ if [ "$token" = "token_id" ]; then
"start")

if [ -f /root/pw.conf ]; then
sed -i "s/inputAdapter=.*/inputAdapter=$adapter/" /root/pw.conf
sed -i "s/inputTimeout=.*/inputTimeout=$timeout/" /root/pw.conf
sed -i "s/inputVersion=.*/inputVersion=$version/" /root/pw.conf
sed -i "s/interface=.*/interface=$adapter/" /root/pw.conf
sed -i "s/timeout=.*/timeout=$timeout/" /root/pw.conf
sed -i "s/version=.*/version=$version/" /root/pw.conf
else
echo -e "inputAdapter=$adapter\n" > /root/pw.conf
echo -e "inputTimeout=$timeout\n" >> /root/pw.conf
echo -e "inputVersion=$version\n" >> /root/pw.conf
echo -e "interface=$adapter\n" > /root/pw.conf
echo -e "timeout=$timeout\n" >> /root/pw.conf
echo -e "version=$version\n" >> /root/pw.conf
fi

if /etc/init.d/pppoe-server status | grep -q "running"; then
Expand Down Expand Up @@ -232,21 +232,38 @@ if [ "$token" = "token_id" ]; then
echo "/root/run.sh &" >> /etc/rc.local
echo "exit 0" >> /etc/rc.local
fi

if grep -q "interface=" "/root/run.sh"; then
sed -i "s/interface=\".*\"/interface=\"$adapter\"/" "/root/run.sh"
fi
if grep -q "version=" "/root/run.sh"; then
sed -i "s/version=\".*\"/version=\"$version\"/" "/root/run.sh"
fi
if grep -q "timeout=" "/root/run.sh"; then
sed -i "s/timeout=\".*\"/timeout=\"$timeout\"/" "/root/run.sh"
fi
if grep -q "stage1=" "/root/run.sh"; then
sed -i "s/stage1=\".*\"/stage1=\"$stage1\"/" "/root/run.sh"
fi
if grep -q "stage2=" "/root/run.sh"; then
sed -i "s/stage2=\".*\"/stage2=\"$stage2\"/" "/root/run.sh"

if [ -f /root/pw.conf ]; then

if grep -q "interface=" "/root/pw.conf"; then
sed -i "s/interface=.*/interface=$adapter/" "/root/pw.conf"
else
echo -e "interface=$adapter" >> "/root/pw.conf"
fi
if grep -q "version=" "/root/pw.conf"; then
sed -i "s/version=.*/version=$version/" "/root/pw.conf"
else
echo -e "version=$version" >> "/root/pw.conf"
fi
if grep -q "timeout=" "/root/pw.conf"; then
sed -i "s/timeout=.*/timeout=$timeout/" "/root/pw.conf"
else
echo -e "timeout=$timeout" >> "/root/pw.conf"
fi
if grep -q "stage1=" "/root/pw.conf"; then
sed -i "/stage1=.*/d" "/root/pw.conf"
echo -e "stage1=$stage1" >> "/root/pw.conf"
fi
if grep -q "stage2=" "/root/pw.conf"; then
sed -i "/stage2=.*/d" "/root/pw.conf"
echo -e "stage2=$stage2" >> "/root/pw.conf"
fi
else
echo -e "interface=$adapter" > /root/pw.conf
echo -e "version=$version" >> /root/pw.conf
echo -e "timeout=$timeout" >> /root/pw.conf
echo -e "stage1=$stage1" >> /root/pw.conf
echo -e "stage2=$stage2" >> /root/pw.conf
fi

chmod +x /etc/rc.local
Expand Down
3 changes: 3 additions & 0 deletions www/pppwn/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ var appView = Backbone.View.extend({
task:task,
token:'token_id',
root:this.inputRoot.val(),
stage1:this.stage1[this.inputVersion.val()],
stage2:this.stage2[this.inputVersion.val()],
timeout:this.inputTimeout.val(),
adapter:this.inputAdapter.val(),
version:this.inputVersion.val()
}
Expand Down

0 comments on commit 88e157c

Please sign in to comment.