![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-11 18:25 |
共 47,811 主题排行 / 349,897 发帖 / 今日 0 篇 / 48,256 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » 原创Tor控制台,第一次出成品,欢迎大大们给点意见 |
| 可打印版本 1,134 / 2 |
| 第1楼 fengwei1980 | 发表于 2009-04-14 06:31 |
| 新手上路 发帖 5 积分 6 | |
|
原创Tor控制台,第一次出成品,欢迎大大们给点意见 代码:
================================================== @echo off &color 0a &&title TOR控制台 今天是:%date% -copyright by Limbor- ::配置项1 设置Tor运行方式,torset值(fetchtorpoint表示开启过滤优化功能,nosetstartor表示关闭过滤及优化功能)建议开启过滤和优化,可以提高速度和安全性! set torset=fetchtorpoint ::配置项2 设置需要过滤Tor节点的国家代码默认(CN中国,HK香港,MO澳门,SG新加坡,PK巴基斯坦,TH泰国,CU古巴,MN蒙古,KP朝鲜,TM土库曼斯坦,UZ乌兹别克斯坦,KZ哈萨克斯坦,VN越南,KG吉尔吉斯斯坦,TJ塔吉克斯坦),具体代码可以上网去查。 set country=CN HK MO SG PK TH CU MN KP TM UZ KZ VN TJ KG TJ ::配置项3 设置优化节点时优先连接的节点带宽最小值(单位kb/s) set bandlevel=1000 ::配置项4 设置Tor节点配置信息的下载地址,保存路径及保存文件名 set url=http://torstatus.kgprog.com/query_export.php/Tor_query_EXPORT.csv ::配置项5 预先设置联网的网络连接名称interface,该连接对应的静态ip,子网掩码mask,网关getway,dns服务器地址。(一般局域网中才用到) set interface=本地连接 set ip=192.168.0.254 set mask=255.255.255.0 set getway=192.168.0.1 set dns1= set dns2= ::配置项6 预先设置TOR启动后跟随启动的程序,一般是firefox set EXE=firefox.exe :ALL ::设置基本变量 set p=%cd% set jud=0 for /f "tokens=1 delims=\" %%i in ('echo %cd%') do set drive=%%i set e=============================================================================== echo %e% echo 说明:1.程序组件列表:Tor控制台.bat,Tor.exe,curl.exe&echo. echo 2.配置本程序请编辑批处理文件中的配置项&echo. echo %e% echo 当前程序配置如下(可在配置项中设定):&echo. if %torset% == fetchtorpoint ( echo Tor节点过滤优化 开启&echo. ) else ( echo Tor节点过滤优化 关闭&echo. ) echo 跟随Tor启动程序 %EXE%&echo. echo %e% :testnet %drive% &&cd %p% >nul 2>nul ping -n 1 -w 1000 www.google.com >nul 2>nul if errorlevel 1 ( echo.&echo.&echo.&echo. echo 注意: 网络未联通,请设置网络... for /l %%a in (1,1,3) do color fc&ping/n 1 127.1>nul&color cf&ping/n 1 127.1>nul ping -n 2 127.1>nul&color 0a goto setnet ) else ( goto jr ) :jr tasklist|findstr /r "%EXE%" >nul 2>nul if not errorlevel 1 ( tasklist|findstr /r "tor.exe" >nul 2>nul if errorlevel 1 goto chbro ) else ( tasklist|findstr /r "tor.exe" >nul 2>nul if not errorlevel 1 ( echo -%date%%time%- Tor连接正常... CALL :ECHPOINT DEL /S /F /Q *.TMP >NUL 2>NUL goto startfirefox ) else ( goto %torset% ) ) :chbro %drive% &&cd %p% >nul 2>nul tasklist|findstr /r "tor.exe" >nul 2>nul if not errorlevel 1 ( set say=Tor连接正常 ) else ( echo.&echo.&echo.&echo. set say=Tor网络未连接 echo 注意:Tor进程未启动,匿名连接请启动Tor进程... for /l %%a in (1,1,3) do color fc&ping/n 1 127.1>nul&color cf&ping/n 1 127.1>nul ping -n 2 127.1>nul&color 0a ) echo %e% echo 状态:%say% %say2% echo %e% echo 1. 清除Tor缓存 2. 更换Tor节点&echo. echo 3. 启动Tor服务/进程 4. 查看Tor节点&echo. echo 5. 断开Tor连接 6. 卸载Tor服务&echo. echo 7. 退出(保留Tor链接) 8. 卸载(清除缓存,结束进程,卸载服务)&echo. echo %e% set /p chbro=请选择: if %chbro% == 1 cd "%windir%\system32" &&rd /s /q TORCache&&md TORCache &&goto chbro if %chbro% == 2 goto TORNEWNYM if %chbro% == 3 goto %torset% if %chbro% == 4 start Tor_query_EXPORT.csv &&goto chbro if %chbro% == 5 taskkill /f /im tor.exe &&goto chbro if %chbro% == 7 exit if %chbro% == 6 tor -remove &&goto chbro if %chbro% == 8 goto config ::通过curl下载tor节点信息 :fetchtorpoint del /s /q /f Tor_query_EXPORT.csv >nul 2>nul echo -%date%%time%- 正在下载Tor节点信息,请稍候... echo %e% curl %url% >Tor_query_EXPORT.csv echo %e%&echo. ::过滤节点不要改动 :excludepoint del /s /f /q Exclude.Nodes.txt >nul 2>nul echo -%date%%time%- 正在配置Tor网络,过滤可疑节点,请稍候... for %%i in (%country%) do findstr /r ",%%i," Tor_query_EXPORT.csv >>Exclude.Nodes0.tmp for /f "delims=" %%i in (Exclude.Nodes0.tmp) do ( if not defined %%i set %%i=A & echo %%i>>Exclude.Nodes1.tmp ) for /f "tokens=1 delims=," %%i in ('findstr /r ".*" Exclude.Nodes1.tmp') do echo %%i >>Exclude.Nodes2.tmp set lnum=0 setlocal enabledelayedexpansion set line=1 for /f "tokens=1* delims=:" %%a in ('findstr /n .* Exclude.Nodes2.tmp') do ( set /a line+=1 ) set /a line0=%line%-1 for /f "delims=" %%i in (Exclude.Nodes2.tmp) do ( set /a lnum+=1 set lstr=!lstr! %%i if !lnum! equ %line0% echo !lstr! && set lnum=0 & set lstr= ) >>Exclude.Nodes.txt set file=Exclude.Nodes.txt set replaced= set all=, setlocal enabledelayedexpansion set "file=%file:"=%" for %%i in ("%file%") do set "file=%%~fi" cd.>"%file%_tmp.txt" for /f "tokens=1* delims=:" %%i in ('findstr /n .* "%file%"') do ( set str=%%j if not "!str!"=="" set "str=!str:%replaced%=%all%!" >>"%file%_tmp.txt" echo.!str! ) move "%file%_tmp.txt" "%file%" :enterpoint del /s /f /q Entry.Nodes.txt >nul 2>nul echo -%date%%time%- 正在配置Tor网络,优化节点,请稍候... for %%i in (%country%) do findstr /r "^" Tor_query_EXPORT.csv >>Entry.Nodes0.tmp for /f "tokens=3 delims=," %%i in ('findstr /r ".*" Entry.Nodes0.tmp') do ( if /i %%i GEQ %bandlevel% ( findstr /r "%%i" Entry.Nodes0.tmp >>Entry.Nodes00.tmp ) ) for /f "delims=" %%i in (Entry.Nodes00.tmp) do ( if not defined %%i set %%i=A & echo %%i>>Entry.Nodes1.tmp ) for /f "tokens=1 delims=," %%i in ('findstr /r ".*" Entry.Nodes1.tmp') do echo %%i >>Entry.Nodes2.tmp set enum=0 setlocal enabledelayedexpansion set line=1 for /f "tokens=1* delims=:" %%a in ('findstr /n .* Entry.Nodes2.tmp') do ( set /a line+=1 ) set /a line1=%line%-1 for /f "delims=" %%i in (Entry.Nodes2.tmp) do ( set /a enum+=1 set lestr=!lestr! %%i if !enum! equ %line1% echo !lestr! && set enum=0 & set lestr= ) >>Entry.Nodes.txt set file=Entry.Nodes.txt set replaced= set all=, setlocal enabledelayedexpansion set "file=%file:"=%" for %%i in ("%file%") do set "file=%%~fi" cd.>"%file%_tmp.txt" for /f "tokens=1* delims=:" %%i in ('findstr /n .* "%file%"') do ( set estr=%%j if not "!estr!"=="" set "estr=!estr:%replaced%=%all%!" >>"%file%_tmp.txt" echo.!estr! ) move "%file%_tmp.txt" "%file%" :setpoint CALL :ECHPOINT for /f %%i in ('findstr "," Exclude.Nodes.tmp') do set EXnickname=%%i for /f %%i in ('findstr "," Entry.Nodes.tmp') do set ENnickname=%%i :nosetstartor ::开启tor服务,添加过滤节点 echo -%date%%time%- 安装Tor服务并启动,配置Tor网络连接:&echo. tor -install -options DataDirectory TorCache %EXnickname% %ENnickname% >nul||tor -remove >nul&&tor -install -options DataDirectory TorCache %EXnickname% %ENnickname% echo.&for /l %%a in (1,1,3) do color a0&ping/n 1 127.1>nul&color 0a&ping/n 1 127.1>nul echo %e% echo -%date%%time%- Tor服务已启动,Tor网络配置完成,请根据浏览器进行代理配置:&echo. echo %e% echo 如果您使用Firefox请安装TorButton插件或其它支持Tor的代理插件控制代理行为。&echo. echo 如果您使用其他浏览器请开启Privoxy并将代理地址设为127.0.0.1:8118。 del /s /q /f "%P%\*.tmp" >nul 2>nul echo %e% :startfirefox taskkill /f /im %EXE% >nul 2>nul echo.&echo -%date%%time%- 正在启动%EXE%程序... start %EXE% set wait=ping -n 2 0 ^>^nul for /l %%n in (20,-1,0) do ( title %wait%) exit :config %drive% &&cd %p% >nul 2>nul echo %e% echo -%date%%time%- 结束相关进程,卸载Tor服务... echo %e% taskkill /f /im tor.exe tor -remove echo %e% echo -%date%%time%- 清理临时文件... echo %e% del /f /s /q "%P%\*.tmp" del /s /q /f "%P%\Entry.Nodes.txt" del /s /q /f "%P%\Exclude.Nodes.txt" del /s /q /f "%P%\Tor_query_EXPORT.csv" %drive% &&cd %p% >nul 2>nul %homedrive% &&cd "%windir%\system32" rd /s /q TorCache echo.&echo 按任意键退出... pause >nul exit :setnet %drive% &&cd %p% >nul 2>nul echo %e% echo 本机使用何种方式联网: echo %e% echo 1. 拨号&echo. echo 2. 自动配置静态地址(局域网/专线)&echo. echo 3. 手动配置静态地址(局域网/专线)&echo. echo 3. 动态地址(局域网/专线)&echo. echo %e% set /p netconf=请选择: if %netconf% == 1 ( rasphone &&goto testnet ) if %netconf% == 2 ( netsh interface ip set address name="%interface%" static %ip% %mask% %getway% netsh interface ip set dns name="%interface%" static %dns1% %dns2% if mmm == 1 goto testnet goto chbro ) if %netconf% == 3 ( echo 请输入(按回车确定): set /p interface=网络连接名称: set /p ip=本机 IP 地址: set /p mask=子网掩码地址: set /p getway=网关 IP 地址: set /p dns1=主要DNS地址 : set /p dns2=备用DNS地址 : netsh interface ip set address name="%interface%" static %ip% %mask% %getway% netsh interface ip set dns name="%interface%" static %dns1% %dns2% if mmm == 1 goto testnet goto chbro ) if %netconf% == 4 ( netsh interface ip set address name="%interface%" source=dhcp netsh interface ip set dns name="%interface%" source=dhcp if mmm == 1 goto testnet goto chbro ) :TORNEWNYM if not exist "%p%\telnet.exe%" ( copy "%windir%\system32\telnet.exe" "%p%\telnet.exe" >nul 2>nul ) %drive% &&cd %p% >nul 2>nul echo AUTHENTICATE >torctrl.txt echo SIGNAL NEWNYM >>torctrl.txt echo QUIT >>torctrl.txt echo -%date%%time%- 正在转换tor节点,请稍候... curl telnet://127.0.0.1:9051 <torctrl.txt >nul 2>nul ping 127.0.0.1 -n 38 >nul del /s /q /f torctrl.txt set say2=-%time%- tor节点转换完毕 goto chbro :ECHPOINT for /f %%i in ('findstr "," Exclude.Nodes.txt') do set Exclude=%%i echo ExcludeNodes %Exclude% >Exclude.Nodes.tmp for /f %%i in ('findstr "," Entry.Nodes.txt') do set Entry=%%i echo EntryNodes %Entry% >Entry.Nodes.tmp echo %e% echo 共有%line0%个可疑节点(国家标识为%country%):&echo. echo 程序将不会连接以下节点(节点名称以","分隔):&echo. echo %Exclude% echo.&echo 共有%line1%个节点可供优化(带宽达到%bandlevel%ks/s以上):&echo. echo 程序将优先连接以下节点(节点名称以","分隔):&echo. echo %Entry% echo %e% |
|
| 第2楼 fengwei1980 | 发表于 2009-04-23 01:15 |
| 新手上路 发帖 5 积分 6 | |
|
没人回,自己顶,呵呵 改了下,做成通用程序,用VBS下载者取代了Curl
有些杀软会报警,自己看下代码,下载地址在那,是Tor官方的服务器日志,不是病毒哦 代码: |
|
| 第3楼 fengwei1980 | 发表于 2009-04-23 01:16 |
| 新手上路 发帖 5 积分 6 | |
|
添加了选择程序和创建快捷方式
|
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |