中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 原创Tor控制台,第一次出成品,欢迎大大们给点意见
作者:
标题: 原创Tor控制台,第一次出成品,欢迎大大们给点意见 上一主题 | 下一主题
fengwei1980
新手上路





积分 6
发帖 5
注册 2008-1-5
状态 离线
『楼 主』:  原创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 "^[,%%i,]" 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 [本窗口%%n秒后自动关闭]
%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%

2009-4-14 06:31
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
fengwei1980
新手上路





积分 6
发帖 5
注册 2008-1-5
状态 离线
『第 2 楼』:  没人回,自己顶,呵呵

改了下,做成通用程序,用VBS下载者取代了Curl
有些杀软会报警,自己看下代码,下载地址在那,是Tor官方的服务器日志,不是病毒哦





代码:
@echo off &color 0a &&title TorCap控制台           今天是:%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=


::设置基本变量
set p=%cd%
for /f "tokens=1 delims=\" %%i in ('echo %cd%') do set drive=%%i
set e===============================================================================
if %torset% == fetchtorpoint (
set say3=Tor节点过滤优化已开启
) else (
set say3=Tor节点过滤优化已关闭
)
:pathju
if exist "path.ini" (
for /f "delims=" %%i in ('findstr /r ".*" path.ini') do set EXE=%%i
goto testnet
)

:setpath
echo Set Of = CreateObject("Scripting.FileSystemObject") >>writepath.vbs
echo Set objFile = oF.createTextFile("Path.ini",2,ture) >>writepath.vbs
echo Set objDialog = CreateObject("UserAccounts.CommonDialog") >>writepath.vbs
echo objDialog.Filter = "exe File|*.exe">>writepath.vbs
echo objDialog.InitialDir = "c:\" >>writepath.vbs
echo tfile=objDialog.ShowOpen >>writepath.vbs
echo if tfile then >>writepath.vbs
echo strLoadFile = objDialog.FileName >>writepath.vbs
echo objFile.Write strLoadFile >>writepath.vbs
echo else >>writepath.vbs
echo wscript.quit >>writepath.vbs
echo end if >>writepath.vbs
echo Set objShell = CreateObject("Wscript.Shell") >>lnk.vbs
echo Set objShellLink = objShell.CreateShortcut("TorCap.lnk") >>lnk.vbs
echo objShellLink.TargetPath = "%p%\TorCap.bat" >>lnk.vbs
echo objShellLink.WindowStyle = 1 >>lnk.vbs
echo objShellLink.Hotkey = ""    >>lnk.vbs
echo objShellLink.Arguments = ""  >>lnk.vbs
echo objShellLink.Description = "匿名连接" >>lnk.vbs
echo objShellLink.IconLocation = "%P%\tor.ico"  >>lnk.vbs
echo objShellLink.WorkingDirectory = "%p%"  >>lnk.vbs
echo objShellLink.Save >>lnk.vbs
echo Set fso = CreateObject("Scripting.FileSystemObject") >>lnk.vbs
echo f = fso.DeleteFile(WScript.ScriptName) >>lnk.vbs
CScript writepath.vbs >NUL
CScript lnk.vbs >NUL
copy TorCap.lnk "%homedrive%\Documents and Settings\%username%\Application Data\Microsoft\Internet Explorer\Quick Launch\TorCap.lnk" >nul 2>nul
copy TorCap.lnk "%homedrive%\Documents and Settings\%username%\桌面\TorCap.lnk" >nul 2>nul
del *.vbs
goto pathju

:testnet
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
       cls
       goto setnet
)
wmic process get ExecutablePath|findstr /r "%EXE%"
if errorlevel 1 (
tasklist|findstr /r "tor.exe" >nul 2>nul
if errorlevel 1 (
set say=Tor网络未连接
goto %torset%
) else (
set say=Tor连接正常
)
) else (
tasklist|findstr /r "tor.exe" >nul 2>nul
if not errorlevel 1 (
set say=Tor连接正常
call :ECHPOINT
goto startfirefox
) else (
set say=Tor网络未连接
goto %torset%
)
)
:chbro
set say2=当前设定连接程序:%EXE%
echo  %e%
echo   当前状态:&echo.
echo        %say%&echo.        
echo        %say3%&echo.
echo        %say2%
echo  %e%
echo   控制选项:&echo.
echo        1. 清除Tor缓存                        2. 更换Tor节点&echo.                              
echo        3. 通过Tor连接                        4. 查看Tor节点&echo.
echo        5. 断开Tor连接                        6. 卸载Tor服务&echo.
echo        7. 退出(保留Tor链接)                8. 卸载(清除缓存,结束进程,卸载服务)
echo  %e%
set chbro=
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

::下载tor节点信息
:fetchtorpoint
del /s /q /f Tor_query_EXPORT.csv >nul 2>nul
echo -%date%%time%- 正在下载Tor节点信息,请稍候...                             

:vbsdown
set downfile=Tor_query_EXPORT.csv
echo Set Post = CreateObject("Msxml2.XMLHTTP") >>vbsdown.vbs
echo Set Shell = CreateObject("Wscript.Shell") >>vbsdown.vbs
echo Post.Open "GET","%url%",0 >>vbsdown.vbs
echo Post.Send() >>vbsdown.vbs
echo Set aGet = CreateObject("ADODB.Stream") >>vbsdown.vbs
echo aGet.Mode = 3 >>vbsdown.vbs
echo aGet.Type = 1 >>vbsdown.vbs
echo aGet.Open() >>vbsdown.vbs
echo aGet.Write(Post.responseBody) >>vbsdown.vbs
echo aGet.SaveToFile "%downfile%",2 >>vbsdown.vbs
echo Set fso = CreateObject("Scripting.FileSystemObject") >>vbsdown.vbs
echo f = fso.DeleteFile(WScript.ScriptName) >>vbsdown.vbs
CScript vbsdown.vbs >nul

::过滤节点不要改动
: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 "^[,%%i,]" 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
%drive% &&cd %p% >nul 2>nul
::开启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%

:startfirefox
echo.&echo -%date%%time%- 正在启动程序连接Tor网络...
REG ADD "HKCU\Software\Bert's Software\FreeCap\SocksChain\00000001" /v Server /d 127.0.0.1 /f >nul 2>nul
REG ADD "HKCU\Software\Bert's Software\FreeCap\SocksChain\00000001" /v Port /d 9050 /f >nul 2>nul
freecapcon "%EXE%"
del /s /q /f "%P%\*.tmp" >nul 2>nul
set wait=ping -n 2 0 ^>^nul
for /l %%n in (20,-1,0) do (
title [本窗口%%n秒后自动关闭]
%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%
REG DELETE "HKCU\Software\Bert's Software\FreeCap\SocksChain\00000001" /f >nul 2>nul
del /f /s /q "%P%\TorCap.lnk"
del /f /s /q "%P%\Path.ini"
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"
del /s /q /f "%homedrive%\Documents and Settings\%username%\Application Data\Microsoft\Internet Explorer\Quick Launch\TorCap.lnk"
del /s /f /q "%homedrive%\Documents and Settings\%username%\桌面\TorCap.lnk"
rd /s /q  "%windir%\system32\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   4. 动态地址(局域网/专线)&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节点转换完毕
del /s /f /q telnet.exe
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%







2009-4-23 01:15
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
fengwei1980
新手上路





积分 6
发帖 5
注册 2008-1-5
状态 离线
『第 3 楼』:  

添加了选择程序和创建快捷方式

2009-4-23 01:16
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: