2013年8月27日星期二
DD-WRT 固件脚本添加与修改
dd-wrt计划任务cron
您可以通过GUI查看到当前的日期和时间:
【状态】->【路由器信息】下的【当前时间】(English:Status/Router/Current Time)
您还可以【管理】->【命令】->【指令解释器】(即shell)界面中输入'date'命令。
确定Cron/Crond 为启用状态.
只需要在“管理”页面中,开启cron。然后输入你要执行的开、关Radio的命令:
2013年8月22日星期四
TOMATO/DD-WRT/DUALWAN成功设置中文SSID的方法(包括中继SSID
dd-wrt中文SSID无线连接名称网络设置方法
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:
- sputnik,chilli,splashd - Host spot management & "Captive Portal" packages.
- pound - a reverse proxy for load balancing.
- kaid - a connector to a global gaming network for game consoles.
- milkfish, asterisk, openser - SIP implementations.
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
2013年8月19日星期一
修改dd-wrt界面风格与替换logo的方法
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:
| Script | Description |
| extract-firmware.sh | Firmware extraction script |
| build-firmware.sh | Firmware re-building script |
Secondary scripts:
| ddwrt-gui-extract.sh | Extracts 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:
- Extract vendor firmware. Then rename the 'fmk' directory.
- Extract third-party 'upgrade' firmware (e.g. Gargoyle-sysupgrade)
- Replace extracted third-party firmware's rootfs and image_parts with those from the vendor firmware.
- Rebuild firmware image
- Flash vendor firmware image (now packaged as your third-party firmware expects).
- 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. |
| AddPattern | Utility to pre-pend Linksys style HDR0 header to a TRX. |
| AddVer | ASUS utility to append a header to a TRX image that contains version information. ASUSTRX includes this capability. Current version: unversioned. |
| Binwalk | Scans firmware images for known file types (firmware headers, compressed kernels, file systems, etc.) |
| CramFSCK | CRAMFS file system image checker and extractor. Current versions included are: 2.4x. |
| CramFSSwap | Utility to swap the endianess of a CramFS image |
| CRCalc | Utility 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. |
| MkCramFS | Builds a cramfs file system image. Coming in next version. Current versions included are: 2.4x. |
| MotorolaBin | Utility that prepends 8 byte headers to TRX images for Motorola devices WR850G, WA840G, WE800G. Current version: unversioned. |
| Splitter3 | Utility to scan and extract a firmware image's component parts. |
| Tpl-tool | Utility 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-LZMA | Alternate tool to extract LZMA-compressed cramfs file system images, such as those used by OpenRG. |
| UnSquashFS | Extracts 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-LZMA | Extracts 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. |
| UnTRX | Splits 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. |
| WebDecomp | Extracts and restores Web GUI files from DD-WRT firmware images, allowing modifications to the Web pages. |
| WRTVxImgTool | Utility to generate VxWorks compatible firmware images for the WRT54G(S) v5 series. |
2013年8月18日星期日
两台dd-wrt路由器的两种连接方法。
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) |
| commit | 742a7cbe5bb3fc75be03151ffdf267c2eafc1ccb (patch) | |
| tree | 70881a77b5186d4c11cc0d710944ebf8a8659e73 | |
| parent | 871a75d5ab4b639ea9f25b2d7baaf2e8122eec76 (diff) | |
| download | firmware-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 |
使用修正版的fmk.
| -rw-r--r-- | src/webcomp-tools/webdecomp.c | 54 |
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端口如何修改
2013年8月2日星期五
更改DD-WRT默认管理端口和修改Nocatsplash端口的方法
2013年8月1日星期四
brand 2.1 二次开发探索
系统的一些变量说明:
- /**
- * 系统的一些变量内容简说
- * $_G 核心变量
- * $_SGLOBAL 系统全局变量信息如(相册分类、商品分类、词语过滤的的储存变量) 该组信息基本不变,除非后台自动生成
- * $_SBLOCK 系统模块信息如(sitenotice、) 该组信息周期更新
- * $_SHTML 未知
- * $_DCACHE 未知
- * $_BCACHE 商城初始化 缓存的class
- * $_SGET 未知
- * $_SC 系统的一配置与数据库连接信息设置
- *
- * 常量信息
- * D_BUG 是否是debug状态
- * A_URL 附件URL地址
- * A_DIR 附件的存放目录
- */
文件说明:
- data/system/config.cache.php 系统配置信息$_G['setting']
- data/system/brandads.cache.php 商城广告信息$_G['brandads']
- data/system/albumcategory.cache.php 相册分类缓存信息$_SGLOBAL['']
- data/system/censor.cache.php 过滤信息$_SGLOBAL['']
- ...
数据库信息说明:
- brand_admincp_group 管理组
- brand_admincp_member 管理员
- brand_admincp_perm 管理员权限
- brand_adminsession 管理员与店铺管理员登录次数与信息判断
- brand_advertisement 广告
- brand_albumitems 相册信息
- brand_attachments 附件表
- brand_attribute 分类自定义属性信息
- brand_attrvalue 分类自定义属性信息内容
- brand_attrvalue_text 分类自定义属性信息内容
- brand_blocks 数据调用
- brand_brandlinks 友情链接
- brand_cache 缓存相关
- brand_cachenotes
- brand_cache_0
- brand_cache_1
- brand_cache_2
- brand_cache_3
- brand_cache_4
- brand_cache_5
- brand_cache_6
- brand_cache_7
- brand_cache_8
- brand_cache_9
- brand_cache_a
- brand_cache_b
- brand_cache_c
- brand_cache_d
- brand_cache_e
- brand_cache_f
- brand_categories 分类
- brand_commentmodels 点评模型
- brand_commentscores 点评分数
- brand_consumeitems 消费券信息
- brand_consumemessage 消费券详细信息
- brand_correctioninfos 纠错信息
- brand_crons 站点的计划任务
- brand_data 广告(未确定)
- /* brand_dlitems 代理信息 */
- brand_gooditems 商品信息
- brand_goodmessage 商品详细信息
- brand_goodrelated 商品的关联信息
- brand_groupbuyitems 团购信息
- brand_groupbuyjoin 会员参团信息
- brand_groupbuymessage 团购的详细信息
- brand_itemattribute (未确定)
- brand_itemupdates 模型的更新信息(未确定)
- brand_members 会员信息
- brand_modelcolumns 模型所有的字段信息
- brand_models 模型
- brand_nav 店铺的导航
- brand_noticeitems 通知公告信息
- brand_noticemessage 通知公告的详细信息
- brand_photoitems 图片信息
- brand_relatedinfo 关联信息(商品关联商品,或关联其它等)
- brand_reportlog 投诉,举报记录
- brand_reportreasons 投诉,举报分类
- brand_scorestats 评分(未确定)
- brand_settings 系统的设置信息
- brand_shopgroup 店铺分类(商户、VIP店铺等)
- brand_shopitems 店铺信息
- brand_shopmapmarks 店铺的地图坐标
- brand_shopmessage 店铺的详细信息
- brand_shopupdate 店铺的更新信息(未确定)
- brand_spacecomments 评论,留言,咨询信息
- brand_stat 每日登录与注册信息统计
- brand_statuser 会员的登录与注册信息统计
- /* brand_xpitems 芯片相关 */
- /* brand_xp_branditems 芯片相关信息位置等 */