2013年8月27日星期二

DD-WRT 固件脚本添加与修改

一.在 \fmk\rootfs\etc\config 目录下新建文件 nocat_liht.sh :

#!/bin/sh
status=`/bin/ps | /bin/grep splashd | /bin/grep -v grep | /bin/wc -l`
#取得nocat状态,必须为1,不能是0,也不能是2
    if [ $status != 1 ];
    then
    /usr/sbin/splashd
   # date >> /tmp/nocat.log #记录出错时间
   # echo "liht_nocat auto restarted" >> /tmp/nocat.log
    else
    exit
    fi

注意:需要管理员登陆linux才能修改rootfs目录,保存后记得修改文件属性为可执行。

二. 修改 \fmk\rootfs\etc\config 目录下的nocat.startup文件,添加如下内容:

if [ "$(nvram get NC_enable)" = "1" ]; then
  * * * * * root /etc/config/nocat_liht.sh
fi

 意思是,如果使用了nocat,就每分钟运行一次脚本。


nocat.sh 
Code:
#!/bin/sh 
X=1 
Y=status 

while [ $X -eq 1 ] 

do 
   sleep 1000 
   cd /tmp 
   sleep 7 
   webup=`ls status` 
     if [ "$Y" != "$webup" ]; then 
          killall wget 
          sleep 5 
          killall splashd 
          echo "nocat restarted" >> nocat.log 
          sleep 20 
          splashd 
          sleep 5 
       else 
          # echo "status deleted" >> nocat.log 
          rm /tmp/status 
     fi 

done 

192.168.2.241 is the ip of the dd-wrt on the lan side 
this check if the status nocat page is working otherwise restarts nocat. The killall comand could be a reboot command if the proccess cannot be killed (depending on the enviroment may be better...). 

I put the script in the startup. 
Code:
chmod +x /tmp/nocat.sh 
/tmp/nocat.sh &

where anyserver is a webserver containing nocat.sh, and accesible for the router 

This work for me, every 24-48 hours nocat need to be restarted. Sometimes nocat depending on global configuration may be too unstable, and the script does not help very much. 

进入 DD-WRT 网页管理界面,Administration -> Commands,贴入如下脚本Save Startup:
mkdir /tmp/myscripts
    /bin/echo ‘#!/bin/sh
    status=`/bin/ps | /bin/grep splashd | /bin/grep -v grep | /bin/wc -l`
    #echo $status

    if [ $status = 0 ];
    then
    /usr/sbin/splashd >> /tmp/nocat.log 2>&1 &
    else
    exit
    fi’ >> /tmp/myscripts/monitor_splash
    /bin/chmod +x /tmp/myscripts/monitor_splash

    /bin/echo ‘ * * * * * root /tmp/myscripts/monitor_splash’ >> /tmp/crontab

    # restart cron daemon
    stopservice cron && startservice cron 

dd-wrt计划任务cron

由于CRON执行命令,至少需要当前时间,DD-WRT的设备的日期和时间通常应设置运行在【NTP】。有时间和日期设置是如此重要,对NTP的配置是直接在位于下基本/设置基本法第一次设置页。

您可以通过GUI查看到当前的日期和时间:

【状态】->【路由器信息】下的【当前时间】(English:Status/Router/Current Time)
您还可以【管理】->【命令】->【指令解释器】(即shell)界面中输入'date'命令。
确定Cron/Crond 为启用状态.



只需要在“管理”页面中,开启cron。然后输入你要执行的开、关Radio的命令:

40 0-6 * * *  root /usr/sbin/wl radio off
0 8 * * *  root /usr/sbin/wl radio on
基本和Linux下的命令一致,只是要注意的是,要在执行的任务前面加上root,才能真正执行。

第一行的含义是在每天晚上12点40到清晨6点40,每隔一个小时执行一次关闭无线的命令。为什么要执行6次呢?因为本人有时候是网迷

,cron执行关闭后,我还会手工打开无线。所以多关闭几次折磨自己。
第二行的含义是在早上8点整打开路由器的无线发射。

分钟、小时、第几天、第几月、每周的第几天
# +---------------- 分钟 (0 - 59)
# |  +--------------小时 (0 - 23)
# |  |  +-----------日 (1 - 31)
# |  |  |  +-------- 月 (1 - 12)
# |  |  |  |  +------每周的第几天 (0 - 6) (周日=0 或 7)
# |  |  |  |  |
*/5 * * * * root /jffs/auto3322.sh
# 每5分钟执行一次
# chmod 777 auto3322.sh

linux下面有atd和crond两种计划任务,其中,atd服务使用的at命令只能执行一次,而crond服务使用的crontab定义的命令,是循环作

用的,所以crond才符合我们的要求。
 crontab支持两种状态:一、直接编写计划任务;二、使用目录的方式,放在目录里面的都会定时执行。

在#!/bin/sh的情况下,source不成功,不会运行source后面的代码。
在#!/bin/bash的情况下,虽然source不成功,但是还是运行了source后面的echo语句。

2013年8月22日星期四

TOMATO/DD-WRT/DUALWAN成功设置中文SSID的方法(包括中继SSID

先telnet到路由器:telnet 192.168.1.1

以下命令TOMATO/DD-WRT/DUALWAN都一样

设置命令如下
nvram set wl_ssid="我的热点"
nvram commit 

说明1:其中的中文最好在命令行里输入,不要复制,两边的引号为半角,不要写错了。
说明2:命令行中的中文(即SSID)输入后应正常显示的,如果为乱码,则可能会导致设置不成功。
说明3:第2条命令执行完,需要等几秒钟,然后会提示:commit...done!表示设置成功。
说明4:设置完成后,DD/TT/DW的页面都会显示为乱码。
说明5:WinXP的无线列表里会显示正常的中文,但连接后的右下角会显示乱码。vista/win7显示正常。
说明5:4,5中的中文显示问题,均不影响正常使用。(呵呵,这条貌似多余?)
说明6:设置完成后,须重起路由器,以便客户端识别新的SSID。

中继后的设置命令如下:
nvram set wl0_ssid="TP-LINK" (其它路由器的SSID)
nvram set wl0.1_ssid="我的热点" (自己路由的SSID)
nvram commit
reboot

dd-wrt中文SSID无线连接名称网络设置方法

两种修改方法任你选
 
  1.浏览器法
 
  设备要求:设备要求比较低,即使没有为无线路由器刷DD-WRT或Tomato等第三方固件也可使用该方法将SSID修改为中文。
 
  固件是DD-WRT的无线路由器,在修改无线网络SSID信息为中文名并保存时提示“无线网络名(SSID)包含非法ASCⅡ码”。这是因为无线路由器管理界面由JSP编写而成,而很多JSP语句对中文字符的支持不好,使用浏览器法的目的就是让无线路由管理界面支持中文编码。
 
  第一步:由于很多无线路由器管理界面都是通过JSP或JAVA程序制作的,所以可通过禁止加载JAVA组件的方式来解除设备对中文SSID无线网络设置的限制。由于默认情况下IE浏览器没有相关功能,只能使用Firefox浏览器来解决。首先通过Firefox浏览器访问无线路由器管理界面,默认情况下会出现乱码。
 
  第二步:在Firefox浏览器的“字符编码”中将语言设定为“中文”后可解决乱码问题。同时在Firefox浏览器中取消对“启用javascript”选项的选择。
 
  第三步:重新刷新管理页面,再次输入中文SSID无线网络设置信息并保存,将不再出现“非法ASCⅡ码”的提示。
  第四步:保存完毕后,通过操作系统的无线扫描功能,可看到SSID修改为中文字符的无线网络。设置完成后,要重新选中Firefox浏览器的“启用javascript”选项,以免日后浏览其他页面时受到影响。

  2.Telnet法
 
  设备要求:此方法要求无线路由器开启了Telnet服务即可,不过并不是所有无线设备都默认开启该服务,在进行操作前需要确定该服务开启。
  只有开启了Telnet服务的无线路由器才能够使用此方法进行设置。
  第一步:一般情况下,刷了DD-WRT或Tomato等第三方固件的无线路由器都会默认开启Telnet功能,而部分D-Link、Linksys无线路由器也有相关功能。只需要通过命令提示符窗口输入“Telnet 无线路由器管理地址”进行检测即可,如果出现要求输入用户名和密码的提示,就说明该功能已经开启。
 
  提示:在Telnet状态下输入的用户名永远是root,而密码则和图形化管理界面中的账户密码一致。
 
  第二步:通过Telnet进入无线路由器命令行管理界面后,可通过nvram set wl_SSID=“中文SSID名称”命令来设置一个中文SSID,例如笔者输入的是nvram set wl_SSID=“阮征”,那么会设置SSID广播网络信息为“阮征”。
 
  第三步:进行修改后,可以实时通过图形管理界面查看SSID信息的更改,不过会出现乱码,不用理会即可。
 
  第四步:接下来在命令行管理界面使用nvram commit命令保存做过的设置,最后通过reboot命令进行重启。

2013年8月20日星期二

修改DD-WRT固件,添加删除功能

Optional steps for users with "Mega" (like me)

The steps below are only applicable if you used the Mega version as your base.
While we have used the "mini" version up until now, some of you may be in possession of a "Mega" capable router (like me).

Personally I found that while Mega has some really nice packages integrated into it out of the box, some are completely useless for my setup, and just take up precious potential JFFS space.

The packages include:

Warning: we will delete everything to do with these packages other then the web pages. this is because, for various reasons, DD-WRT pre-compiles the ASP pages directly into the apache binary, making it impossible to remove them with the mod-kit alone. (yes this was deliberate :\ ).
Therefore it is up to you to remember not to use the web-GUI options, for the packages above.
If your uncertain that you can do this, you may opt to use the "standard" version as your base instead of Mega, or simply skip this procedure.

To delete the packages (despite leaving the web-GUI configurations in place) issue the following commands:
rm ./working_dir*/rootfs/usr/sbin/sputnik  rm ./working_dir*/rootfs/usr/sbin/splashd  rm ./working_dir*/rootfs/usr/sbin/pound  rm ./working_dir*/rootfs/usr/sbin/kaid  rm ./working_dir*/rootfs/usr/sbin/chilli     for i in $( find ./ -name *milkfish* ); do ll $i ;rm -rfv $i ; done  for i in $( find ./ -name *asterisk* ); do ll $i ;rm -rfv $i ; done  for i in $( find ./ -name *openser* ); do ll $i ;rm -rfv $i ; done

原文地址:

http://hotfortech.wikispaces.com/DD-WRT+mod-kit+home+setup

2013年8月19日星期一

修改dd-wrt界面风格与替换logo的方法

http://www.xin100.com/  完美修改

参考了下文:

Firmware Mod Kit

Introduction

The Firmware Mod Kit allows for easy deconstruction and reconstruction of firmware images for various embedded devices. While it primarily targets Linux based routers, it should be compatible with most firmware that makes use of common firmware formats and file systems such as TRX/uImage and SquashFS/CramFS.

Prerequisites

In order to use the Firmware Mod Kit, you must have a subversion client, standard Linux development tools (gcc, make, etc), the python-magic module, and the zlib and lzma development packages. If you are running an linux distro that use apt-get, e.g. Ubuntu or Debian, use:

For Ubuntu:

  $ sudo apt-get install git build-essential zlib1g-dev liblzma-dev python-magic

OR for RedHat:

  yum groupinstall "Development Tools"
yum install git zlib1g
-dev xz-devel python-magic

For other distros, you should install the equivalent packages using your distro's package manager.

The Firmware Mod Kit is only supported on the Linux platform. With a few small modifications, it should work on other POSIX platforms.

Using the Kit

Kit Executables

The Firmware Mod Kit is a collection of utilities and shell scripts. The utilities can be used directly, or the shell scripts can be used to automate and combine common firmware operations (e.g. extract and rebuild). The core scripts to facilitate firmware operations are listed below.

Primary scripts:

ScriptDescription
extract-firmware.shFirmware extraction script
build-firmware.sh Firmware re-building script

Secondary scripts:

ddwrt-gui-extract.shExtracts Web GUI files from extracted DD-WRT firmware.
ddwrt-gui-rebuild.sh Restores modified Web GUI files to extracted DD-WRT firmware.

The Firmware Working Directory

The Firmware Mod Kit uses a 'hard coded' working directory of 'fmk'. The extraction script extracts to this folder, and the rebuild script rebuilds from this folder. Allowance of alternate working directories is supported for some operations, but not all. We'll be expanding that in the future. For now, if you have multiple working directories, we suggest you rename the ones you're not currently operating on.

Extracting Firmware

Automated firmware extraction typically works with most firmware images that employ uImage/TRX firmware headers and use SquashFS or CramFS file systems. Currently, extract-firmware.sh is the preferred method of extraction as it supports more firmware types than the older old-extract.sh script. However, old-extract.sh is still included and works with many firmware formats.

Usage for both extract-firmware.sh and extract_firmware.sh is straight forward:

    $ ./extract-firmware.sh firmware.bin

By default, output from extract-firmware.sh will be located in the 'fmk' directory, while old-extract.sh will place extracted data into the specified working directory.

Re-Building Firmware

Which build script to use is dependant on which extraction script was used. If you extracted a firmware image with extract-firmware.sh, then you must use build-firmware.sh to re-build it. Likewise, if old-extract.sh was used, then old-build.sh must be invoked when re-building an image:

    $ ./build-firmware.sh [-nopad] [-min]

The new firmware generated by build-firmware.sh will be located at 'fmk/new-firmware.bin', while old-build.sh will generate firmware images in several different formats and save them in the specified output directory.

The optional -nopad switch will instruct build-firmware.sh to NOT pad the firmware up to its original size.

The optional -min switch will use the maximum squashfs block size of 1MB. This will decrease the firmware image size at the cost of additional CPU and RAM resources utilized on the target device. Do not use this switch unless you must. This is a very large block size for embedded systems. The original firmware squashfs block size is preserved on rebuild, and the original block size should be the one used unless you are sure you know what you're doing. Too large a block size may appear to work fine, but runtime performance of the firmware may suffer in all or some loads.

Modifying DD-WRT Web Pages

One very unique feature of the Firmware Mod Kit is its ability to extract and rebuild files from the DD-WRT Web GUI. This is automated by the ddwrt-gui-extract.sh and ddwrt-gui-restore.sh scripts.

Once you have extracted a DD-WRT firmware image using extract-firmwware.sh, you can extract the Web files by running:

    $ ./ddwrt-gui-extract.sh

This will create a directory named 'www' and extract the Web files there. You may modify the files any way you like, but you cannot add or delete files.

When you are finished editing, you can rebuild the Web files by running:

    $ ./ddwrt-gui-rebuild.sh

Reverting to a vendor firmware

Sometimes you'll enthusiastically flash a third-party firmware like Gargoyle or DD-WRT only to discover it lacks features you need, doesn't perform as well as the vendor firmware, or has functional problems. In this situation, you might find yourself wanting to go back to the vendor firmware, but have no way to do so!

Here's how the Firmware Mod Kit can help you revert to a vendor firmware. The process is this:

  1. Extract vendor firmware. Then rename the 'fmk' directory.
  2. Extract third-party 'upgrade' firmware (e.g. Gargoyle-sysupgrade)
  3. Replace extracted third-party firmware's rootfs and image_parts with those from the vendor firmware.
  4. Rebuild firmware image
  5. Flash vendor firmware image (now packaged as your third-party firmware expects).
  6. If all succeeded, you're now using the vendor firmware again.

Once you are back to the vendor firmware, then it accepts vendor firmware images again.

Examples

This example demonstrates how to extract a firmware image, replace its existing telnet daemon with a custom built one, and then build a new firmware image:

    $ ./extract-firmware.sh firmware.bin
  $ cp
new-telnetd fmk/rootfs/usr/sbin/telnetd
  $
./build-firmware.sh

Below is an example of the commands to run in order to extract a DD-WRT firmware image, modify the Web index page, and build a new firmware image:

    $ ./extract-firmware.sh firmware.bin
  $
./ddwrt-gui-extract.sh
  $ echo
"HELLO WORLD" > www/index.asp
  $
./ddwrt-gui-rebuild.sh
  $
./build-firmware.sh

Tools / Utilities

The Firmware Mod Kit consists of a collection of tools useful when working with embedded firmware images. These include those listed below, though there are MANY MORE that are not listed here.

Tool Description
AsusTRX An extended version of ASUSTRX that can build both 'normal' TRX files and, optionally, those with an ASUS addver style header appended. It can also, uniquely, force segment offsets in the TRX (with -b switch) for compatibility with Marvell ASUS devices like the WL-530g. This tool replaces both 'normal' trx tool and addver. Current versions included are: 0.90 beta.
AddPatternUtility to pre-pend Linksys style HDR0 header to a TRX.
AddVerASUS utility to append a header to a TRX image that contains version information. ASUSTRX includes this capability. Current version: unversioned.
BinwalkScans firmware images for known file types (firmware headers, compressed kernels, file systems, etc.)
CramFSCKCRAMFS file system image checker and extractor. Current versions included are: 2.4x.
CramFSSwapUtility to swap the endianess of a CramFS image
CRCalcUtility to patch all uImage and TRX headers inside a given firmware image.
MkSquashFS Builds a squashfs file system image. Current versions included are: 2.1-r2, 3.0.
MkCramFSBuilds a cramfs file system image. Coming in next version. Current versions included are: 2.4x.
MotorolaBinUtility that prepends 8 byte headers to TRX images for Motorola devices WR850G, WA840G, WE800G. Current version: unversioned.
Splitter3Utility to scan and extract a firmware image's component parts.
Tpl-toolUtility to manipulate TP-Link vendor format images.
UnCramFS Alternate tool to extract a cramfs file system image. Use cramfsck instead whenever possible as it seems to be more reliable. Current versions included are: 0.7 (for cramfs v2.x).
UnCramFS-LZMAAlternate tool to extract LZMA-compressed cramfs file system images, such as those used by OpenRG.
UnSquashFSExtracts a zlib squashfs file system image. Current versions included are 1.0 for 3.0 images and 1.0 for 2.x images (my own blend).
UnSquashFS-LZMAExtracts an lzma squashfs file system image. Current versions included are 1.0 for 3.0 images and 1.0 for 2.x images (my own blend). Note: Not all squashfs-lzma patches are compatible with one another. I'm working on adding support for all common squashfs-lzma variations.
UnTRXSplits TRX style firmwares into their component parts. Also supports pre-pended addpattern HDR0 style headers. This was developed exclusively for this kit. Current versions included are: 0.45.
WebDecompExtracts and restores Web GUI files from DD-WRT firmware images, allowing modifications to the Web pages.
WRTVxImgToolUtility to generate VxWorks compatible firmware images for the WRT54G(S) v5 series.


2013年8月18日星期日

两台dd-wrt路由器的两种连接方法。

方法1,第二台路由器的WLAN口接第一台的LAN口。

需要注意,两台不能使用同一网段IP。
两台都可以使用DHCP,
只用设置第二台路由的WAN外网为动态获取第一台分配的IP,保存即可

方法2,第二台路由器的LAN口接第一台的LAN口。

关闭DHCP,网关设置为第一台路由的Ip即可。

2013年8月14日星期三

DD-WRT Firmware Mod Kit 重新封装gui时提示www目录为空的修复

author荒野无灯2013-05-05 23:29:44 (CST)
committer荒野无灯2013-05-05 23:29:44 (CST)
commit742a7cbe5bb3fc75be03151ffdf267c2eafc1ccb (patch)
tree70881a77b5186d4c11cc0d710944ebf8a8659e73
parent871a75d5ab4b639ea9f25b2d7baaf2e8122eec76 (diff)
downloadfirmware-mod-kit-742a7cbe5bb3fc75be03151ffdf267c2eafc1ccb.zip
firmware-mod-kit-742a7cbe5bb3fc75be03151ffdf267c2eafc1ccb.tar.gz
firmware-mod-kit-742a7cbe5bb3fc75be03151ffdf267c2eafc1ccb.tar.bz2

此bug会导致ddwrt-gui-rebuild.sh 无法重新打包ddwrt的GUI组件. 原因在于,后面的 detect_key(httpd, www); 还要对www文件进行读取。 而原版程序在此之前就已经以二进制写方式打开了www文件: fp = fopen(www, "wb"); 这个操作将导致www文件直接变成0字节的文件。因此,后面的读取操作只会读取到 一个0字节的www文件,从而导致无法顺利打包。

可以直接

1
git clone git://ihacklog.com/firmware-mod-kit.git

使用修正版的fmk.

修正restore函数中一处bug.
此bug会导致ddwrt-gui-rebuild.sh 无法打包ddwrt的GUI组件. 原因在于,后面的 detect_key(httpd, www); 还要对www文件进行读取。 而原版程序在此之前就已经以二进制写方式打开了www文件: fp = fopen(www, "wb"); 这个操作将导致www文件直接变成0字节的文件。因此,后面的读取操作只会读取到 一个0字节的www文件,从而导致无法顺利打包。
-rw-r--r--src/webcomp-tools/webdecomp.c 54
1 files changed, 29 insertions, 25 deletions
diff --git a/src/webcomp-tools/webdecomp.c b/src/webcomp-tools/webdecomp.c
index d2bb8db..b67cfd4 100644
--- a/src/webcomp-tools/webdecomp.c
+++ b/src/webcomp-tools/webdecomp.c
@@ -34,7 +34,7 @@ int main(int argc, char *argv[])
};
memset((void *) &globals, 0, sizeof(globals));
-
+
while((c = getopt_long(argc, argv, short_options, long_options, &long_opt_index)) != -1)
{
switch(c)
@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
default:
usage(argv[0]);
goto end;
-
+
}
}
@@ -191,7 +191,7 @@ int extract(char *httpd, char *www, char *outdir, char *key)
/* Read in the httpd and www files */
hdata = (unsigned char *) file_read(httpd, &hsize);
wdata = (unsigned char *) file_read(www, &wsize);
-
+
if(hdata != NULL && wdata != NULL && detect_settings(hdata, hsize))
{
/* Detect the key */
@@ -205,7 +205,7 @@ int extract(char *httpd, char *www, char *outdir, char *key)
{
perror(outdir);
}
- else
+ else
{
/* Get the next entry until we get a blank entry */
while((info = next_entry(hdata, hsize)) != NULL)
@@ -257,13 +257,13 @@ int extract(char *httpd, char *www, char *outdir, char *key)
{
fprintf(stderr, "\nERROR opening keyfile, aborting\n");
n=-1;
- }
+ }
else
{
if(fwrite(&globals.key, 1, sizeof(globals.key), fp) != sizeof(globals.key))
{
fprintf(stderr, "\nERROR writing keyfile, aborting\n");
- n=-1;
+ n=-1;
}
fclose(fp);
}
@@ -289,7 +289,7 @@ int restore(char *httpd, char *www, char *indir, char *key)
struct entry_info *info = NULL;
unsigned char *hdata = NULL, *fdata = NULL;
char origdir[FILENAME_MAX] = { 0 };
- char *path = NULL;
+ char *path = NULL;
if(key)
{
@@ -314,31 +314,35 @@ int restore(char *httpd, char *www, char *indir, char *key)
/* Read in the httpd file */
hdata = (unsigned char *) file_read(httpd, &hsize);
-
+
/* Get the current working directory */
getcwd((char *) &origdir, sizeof(origdir));
- /* Open the www file for writing */
- fp = fopen(www, "wb");
-
- if(hdata != NULL && fp != NULL && detect_settings(hdata, hsize))
+ if(hdata != NULL && detect_settings(hdata, hsize))
{
/* Detect the key */
detect_key(httpd, www);
+ /* Open the www file for writing */
+ fp = fopen(www, "wb");
+ if( fp == NULL )
+ {
+ fprintf(stderr,"failed to open www file for writing \n");
+ }
+
/* Change directories to the target directory */
- if(chdir(indir) == -1)
- {
- perror(indir);
- }
- else
+ if(chdir(indir) == -1)
+ {
+ perror(indir);
+ }
+ else
{
/* Get the next entry until we get a blank entry */
while((info = next_entry(hdata, hsize)) != NULL)
{
/* Count the number of files we process */
n++;
-
+
/* Make sure the full file path is safe (i.e., it won't overwrite something critical on the host system) */
path = make_path_safe(info->name);
if(path)
@@ -348,18 +352,18 @@ int restore(char *httpd, char *www, char *indir, char *key)
/* Read in the file */
fdata = (unsigned char *) file_read(path, &fsize);
-
+
/* Update the entry size and file offset */
if(globals.use_new_format)
{
- info->new_entry->size = fsize + globals.key;
+ info->new_entry->size = fsize + globals.key;
}
else
{
info->entry->size = fsize;
info->entry->offset = total;
}
-
+
/* Byte swap, if necessary */
hton_entries(info);
@@ -375,17 +379,17 @@ int restore(char *httpd, char *www, char *indir, char *key)
/* Update the total size written to the www blob */
total += fsize;
}
-
+
free(fdata);
}
-
+
free(path);
}
else
{
fprintf(stderr, "File path '%s' is not safe! Skipping...\n", info->name);
}
-
+
free(info);
}
@@ -408,7 +412,7 @@ int restore(char *httpd, char *www, char *indir, char *key)
{
perror("restore");
}
-
+
if(fp) fclose(fp);
if(hdata) free(hdata);
return n;

更改DD-WRT的默认配置基本步骤,firmware_mod_tools.tar.gz 下载

1)     从DDWRT网站上下载DDWRT的固件,假定文件名dd-wrt.v24_mini_wrt54g.bin

2)     下载最新的firmware_mod_tools.tar.gz,解压之  http://code.google.com/p/firmware-mod-kit/downloads/detail?name=fmk_099.tar.gz&can=2&q=

$tar xzf firmware_mod_tools.tar.gz

3)     使用firmware_mod_tools解析DDWRT固件

$cd firmware_mod_tools

$./extract_firmware.sh ../dd-wrt.v24_mini_wrt54g.bin ../work_dir

$cd –

4)     打开work_dir/rootfs/etc下面的preinit文件,在末尾添加上新的配置,如下所示:

default_settings=`nvram get default_settings`

if [ -z “$default_settings”]; then

nvram set default_settings=1

nvram set cron_enable=0 #设置cron默认不启动

nvram set ntp_enable=0  #设置NTP默认为Disable

…..

fi

5)      用firmware_mod_tools重新整合DDWRT固件

$cd firmware_mod_tools

$./build_firmware.sh ../out_dir ../work_dir

$cd -

新的固件将被放置到文件夹out_dir中

2013年8月4日星期日

ddwrt系统,路由器默认的80端口如何修改

ddwrt系统,路由器默认的80端口如何修改啊
首先telnet 192.168.1.1进去
root@Router:~# nvram show | grep NC_

nvram set http_lanport=76
nvram commit
reboot


 
先打开IP转发功能:
echo "1">/proc/sys/net/ipv4/ip_forward
通过以下命令可以查到返回值为1,表示打开成功
cat /proc/sys/net/ipv4/ip_forward

2013年8月2日星期五

更改DD-WRT默认管理端口和修改Nocatsplash端口的方法

telnet到路由,用nvram命令更改httpd以及ssh服务的端口。
具体方法是: 
代码:
# telnet 192.168.1.1
# nvram set rc_startup="
> killall httpd
> cd /www
> httpd -p 81 -h /www
> dropbear -b /tmp/loginprompt -r /tmp/root/.ssh/ssh_host_rsa_key -d /tmp/root/.ssh/ssh_host_dss_key -p 80
> "
# nvram commit
输入第二行(nvram set rc_startup=")后,提示符会从#变成>,这时候再输入需要自动执行的命令,最后输入双引号回车结束
nvram commit是把刚才需要执行的命令保存到路由的flash,这样掉电重启才有用
另外可以用nvram get rc_startup查看输入的命令是否正确)



DD-WRT开启Nocatsplash通告功能
root@Router:~# nvram show | grep NC_
NC_Verbosity=2
NC_RenewTimeout=0
NC_SplashURL=http://www.xin100.com/splash.html  #没法修改内置通告文件的内容,所以只好引用外部地址
NC_MaxMissedARP=5
NC_MACWhiteList=
NC_DocumentRoot=/www
NC_ifname=br0
NC_LeaseFile=/tmp/nocat.leases
NC_RouteOnly=1
NC_GatewayPort=5280
NC_SplashURLTimeout=180  #一个超时计时器,酌情调节。(单位是秒)
NC_IncludePorts=53 80 443  #这是允许的端口列表,只能在telnet下调,这么设置【nvram set NC_IncludePorts="53 80 443"】,内容加引号,端口之间用空格分隔。
NC_GatewayName=Free Wi-Fi
NC_ExcludePorts=  #排除端口,上面允许端口设置完了,这里就不要设了
NC_enable=1
size: 22038 bytes (10730 left)
NC_GatewayAddr=192.168.1.1  #网关地址(这个是本地LAN口IP)
NC_LoginTimeout=120  #又一个超时计时器,酌情调节。(单位是秒)
NC_GatewayMode=Open
NC_IdleTimeout=0
NC_ForcedRedirect=0
NC_AllowedWebHosts=acctc.com

2013年8月1日星期四

brand 2.1 二次开发探索

brand 2.1 

系统的一些变量说明: 
Php代码  收藏代码
  1. /** 
  2.  * 系统的一些变量内容简说 
  3.  * $_G        核心变量 
  4.  * $_SGLOBAL  系统全局变量信息如(相册分类、商品分类、词语过滤的的储存变量)   该组信息基本不变,除非后台自动生成 
  5.  * $_SBLOCK   系统模块信息如(sitenotice、)  该组信息周期更新 
  6.  * $_SHTML    未知 
  7.  * $_DCACHE   未知 
  8.  * $_BCACHE   商城初始化 缓存的class 
  9.  * $_SGET     未知 
  10.  * $_SC       系统的一配置与数据库连接信息设置 
  11.  *  
  12.  * 常量信息 
  13.  * D_BUG  是否是debug状态 
  14.  * A_URL  附件URL地址 
  15.  * A_DIR  附件的存放目录 
  16.  */  


文件说明: 
Java代码  收藏代码
  1. data/system/config.cache.php 系统配置信息$_G['setting']  
  2. data/system/brandads.cache.php 商城广告信息$_G['brandads']  
  3. data/system/albumcategory.cache.php 相册分类缓存信息$_SGLOBAL['']  
  4. data/system/censor.cache.php 过滤信息$_SGLOBAL['']  
  5. ...  


数据库信息说明:
Java代码  收藏代码
  1. brand_admincp_group 管理组  
  2. brand_admincp_member 管理员  
  3. brand_admincp_perm 管理员权限  
  4. brand_adminsession 管理员与店铺管理员登录次数与信息判断  
  5. brand_advertisement 广告  
  6. brand_albumitems 相册信息  
  7. brand_attachments 附件表  
  8. brand_attribute 分类自定义属性信息  
  9. brand_attrvalue 分类自定义属性信息内容  
  10. brand_attrvalue_text 分类自定义属性信息内容  
  11. brand_blocks 数据调用  
  12. brand_brandlinks 友情链接  
  13. brand_cache 缓存相关  
  14. brand_cachenotes  
  15. brand_cache_0  
  16. brand_cache_1  
  17. brand_cache_2  
  18. brand_cache_3  
  19. brand_cache_4  
  20. brand_cache_5  
  21. brand_cache_6  
  22. brand_cache_7  
  23. brand_cache_8  
  24. brand_cache_9  
  25. brand_cache_a  
  26. brand_cache_b  
  27. brand_cache_c  
  28. brand_cache_d  
  29. brand_cache_e  
  30. brand_cache_f  
  31. brand_categories 分类  
  32. brand_commentmodels 点评模型  
  33. brand_commentscores 点评分数  
  34. brand_consumeitems 消费券信息  
  35. brand_consumemessage 消费券详细信息  
  36. brand_correctioninfos 纠错信息  
  37. brand_crons 站点的计划任务  
  38. brand_data 广告(未确定)  
  39. /* brand_dlitems 代理信息 */  
  40. brand_gooditems 商品信息  
  41. brand_goodmessage 商品详细信息  
  42. brand_goodrelated 商品的关联信息  
  43. brand_groupbuyitems 团购信息  
  44. brand_groupbuyjoin 会员参团信息  
  45. brand_groupbuymessage 团购的详细信息  
  46. brand_itemattribute (未确定)  
  47. brand_itemupdates 模型的更新信息(未确定)  
  48. brand_members 会员信息  
  49. brand_modelcolumns 模型所有的字段信息  
  50. brand_models 模型  
  51. brand_nav 店铺的导航  
  52. brand_noticeitems 通知公告信息  
  53. brand_noticemessage 通知公告的详细信息  
  54. brand_photoitems 图片信息  
  55. brand_relatedinfo 关联信息(商品关联商品,或关联其它等)  
  56. brand_reportlog 投诉,举报记录  
  57. brand_reportreasons 投诉,举报分类  
  58. brand_scorestats 评分(未确定)  
  59. brand_settings 系统的设置信息  
  60. brand_shopgroup 店铺分类(商户、VIP店铺等)  
  61. brand_shopitems 店铺信息  
  62. brand_shopmapmarks 店铺的地图坐标  
  63. brand_shopmessage 店铺的详细信息  
  64. brand_shopupdate 店铺的更新信息(未确定)  
  65. brand_spacecomments 评论,留言,咨询信息  
  66. brand_stat 每日登录与注册信息统计  
  67. brand_statuser 会员的登录与注册信息统计  
  68. /* brand_xpitems 芯片相关 */  
  69. /* brand_xp_branditems 芯片相关信息位置等 */