DLINK-DSL500-ADSL-初探(四)- tftp功能
<P>前几天对ADSL-DLINK500做了初步的分析,把里面被“汉化”掉的高级功能找了出来,<BR> 内容在这个帖子上:<BR><STRONG> <a href="http://bbs.bc-cn.net/viewthread.php?tid=133532" target="_blank" > [原创](adsl)DLINK-DSL500-BusyBox on dsl-gateway-初探(一)(二)(三)</A><BR></STRONG><BR>这次重点放在ADSL内部的linux系统上,<BR>用ps -ef查看后可以看到很多服务进程:<BR># ps -ef<BR> PID Uid VmSize Stat Command<BR> 1 root 1272 S init<BR> 2 root S [keventd]<BR> 3 root R [ksoftirqd_CPU0]<BR> 4 root S [kswapd]<BR> 5 root S [bdflush]<BR> 6 root S [kupdated]<BR> 7 root S [mtdblockd]<BR> <STRONG><FONT color=#ff0000>32 root 1168 S /usr/sbin/thttpd -d /usr/www -u root -p 80 -c /cgi-b</FONT></STRONG><BR> 33 root 1784 S /usr/bin/cm_pc<BR> 35 root 1272 S init<BR> <STRONG><FONT color=#ff0000>36 root 2864 S /usr/bin/cm_logic -m /dev/ticfg -c /etc/config.xml</FONT></STRONG><BR> 37 root 1280 S /usr/bin/cm_monitor<BR> 48 root 632 S /sbin/dproxy -c /etc/resolv.conf -d<BR> 99 root 672 S /usr/sbin/udhcpd /var/tmp/udhcpd.conf<BR> 101 root 2340 S /usr/sbin/pppd plugin pppoe nas7 user <a href="mailto:ta1*****38@e" target="_blank" >ta1*****38@e</A> p<BR> 121 root 616 S /sbin/utelnetd<BR> 122 root 1276 S -sh<BR> 124 root 1272 R ps -ef<BR>=============================================</P><P>我重点看了上面标红的两行,thttpd的现实被截断了,不过在/etc/init.d/rcS脚本中,<BR>看到了这句话的完整内容:<BR>/usr/sbin/thttpd -d /usr/www -u root -p 80 -c '/cgi-bin/*'<BR>它指定web服务的主目录,端口和cgi脚本。</P>
<P>从cm_logic的帮助中看到它的用法:<BR>cm_logic -h<BR> Prints this help message.</P>
<P>cm_logic -c /path/to/config.xml<BR> Uses XML file on a filesystem for configuration.</P>
<P>cm_logic -m /path/to/mtdblock/device -c /path/to/config.xml<BR> Uses raw MTD block for configuration. If MTD is corrupted, it will be po<BR>pulated with XML file.</P>
<P><FONT color=#ff0000><FONT color=#000000>所以</FONT> <STRONG>/dev/ticfg </STRONG><FONT color=#000000>和 </FONT><STRONG>/etc/config.xml </STRONG><FONT color=#000000>的内容应该是一样的,我用cat命令查看了他们。<BR>帮助的最后一行也有:如果ticfg出了意外,就用config.xml来重建ticfg。</FONT></FONT></P>
<P>===========================================</P>
<P>接下来看一下那个tftp的小东西,在/usr/bin中:<BR># cd /usr/bin<BR># ls<BR>[ cm_logic free test wget<BR>cm_cli cm_monitor id tftp whoami<BR>cm_convert cm_pc passwd tty yes<BR>=============================================<BR>我们知道,tftp是一个非常简单的文件传输协议,一般只有上传和下载功能,<BR>不可以列出目录,但对于嵌入式linux的开发,确实非常优秀的工具。<BR>我从网上找了个<STRONG>Cisco TFTP Server V1.1 汉化版.rar</STRONG>,设定好主目录,<BR>在里面放了个xuhua.txt,内容是“xuhua, tftp succ ...”。</P>
<P>这样windows2003上<BR>就开启了tftp服务,回到ADSL的telnet界面,测试一下tftp的get(上传)命令:<BR># tftp -g -l /var/xuhua.txt -r xuhua.txt 192.168.1.13<BR># cat /car/xuhua.txt<BR>xuhua, tftp succ ...<BR>==============================<BR>再测试一下put上传命令,我把/etc/init.d/rcS传到我的本本上:<BR># tftp -p -l /etc/init.d/rcS -r rcS 192.168.1.13</P>
<P>在<STRONG>Cisco TFTP Server </STRONG>指定的根目录中找到rcS,用记事本打开:<BR>摘录部分内容:<BR>==============================================<BR>#! /bin/sh<BR>#<BR># rcS Call all S??* scripts in /etc/rcS.d in<BR># numerical/alphabetical order.<BR>#<BR># Version: @(#)/etc/init.d/rcS 2.76 19-Apr-1999 <a href="mailto:miquels@cistron.nl" target="_blank" >miquels@cistron.nl</A><BR>#<BR>trap "" SIGHUP</P>
<P>PATH=/sbin:/bin:/usr/sbin:/usr/bin<BR>runlevel=S<BR>prevlevel=N<BR>umask 022<BR>export PATH runlevel prevlevel<BR>....<BR>....(省略)<BR>....<BR># UPnP requires loopback<BR>ifconfig lo 127.0.0.1</P>
<P>/usr/sbin/thttpd -d /usr/www -u root -p 80 -c '/cgi-bin/*'<BR>/usr/bin/cm_pc > /dev/tts/0 &<BR>================================================<BR>这样我们就可以和ADSL进行数据交换了,让我看看/etc里面的内容:<BR># ls /etc -a<BR>.nautilus-metafile.xml host.conf resolv.conf<BR>config.xml hosts securetty<BR>dproxy.conf init.d services<BR>dropbear inittab shadow<BR>firewall_start led.conf shells<BR>firewall_stop linux-igd strings.xml<BR>flush_firewall passwd sysdef.xml<BR>fstab ppp udhcpc<BR>gateways progdefs.xml udhcpd.conf<BR>group protocols versions<BR>===========================================<BR>看到了不少conf和xml吧,我认为有必要把它们tftp -p 到咱们的pc上<BR>好好研究一下,<IMG src="http://blog.bc-cn.net/editor/images/emot/face2.gif"> 。。。<BR>困了,午觉 。。。<BR></P>
页:
[1]
