Analisi Rete di Zangune Code
Find information to forward eMule ports
Status: Alpha
Brought to you by:
zangune
::::::::::::::::::::::::::::::
:: Copyright info at bottom ::
::::::::::::::::::::::::::::::
::
@ECHO OFF
::
:: Start delayed expansion, it's needed by GetMac and GetIp, no end
::
SETLOCAL EnableDelayedExpansion
::
:: Find Windows version through registry, differences between Windows
:: versions exists, in exaple XP is "Microsoft Windows XP" but Windows 8
:: is "Windows 8", without "Microsoft"
::
FOR /F "TOKENS=3*" %%V in (
'REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
/v ProductName ^|FIND "REG_SZ"') DO SET TempWindowsVersion=%%W
::
:: Clean up, remove "Windows", if present
::
SET TempWindowsVersion=%TempWindowsVersion:Windows =%
::
:: Clean up, remove anything but the first word
::
FOR %%C IN (%TempWindowsVersion%) DO (
IF NOT DEFINED WindowsVersion SET WindowsVersion=%%C
)
::
:: Find Windows bitness by checking Program Files (x84) directory existence
::
IF DEFINED ProgramFiles(x86) (
SET WindowsNumberOfBits=64
) ELSE (
SET WindowsNumberOfBits=32
)
::
:: Find eMule config folder, it works for standard eMule installations only
::
IF NOT DEFINED LOCALAPPDATA (
SET eMuleOsConfigRootDir=%PROGRAMFILES%
) ELSE (
SET eMuleOsConfigRootDir=%LOCALAPPDATA%
)
SET eMuleConfigDir=%eMuleOsConfigRootDir%\eMule\config
SET PreferencesIni="%eMuleConfigDir%\preferences.ini"
::
:: Find all eMule ports, based upon the above preferences.ini
::
FOR /F "TOKENS=2 DELIMS==" %%P IN ('FINDSTR "ProxyPort=" %PreferencesIni%') DO ^
SET ProxyPort=%%P
::
:: Find TCP port, based upon that this is the firts occurrence of "Port"
::
FOR /F "TOKENS=2 DELIMS==" %%T IN ('FINDSTR/B "Port=" %PreferencesIni%') DO ^
IF NOT DEFINED TcpPort SET TcpPort=%%T
::
:: Find UDP port, define TCP first
::
FOR /F "TOKENS=2 DELIMS==" %%U IN ('FINDSTR/B "UDPPort=" %PreferencesIni%') DO ^
IF NOT %TcpPort%==%%U SET UdpPort=%%U
FOR /F "TOKENS=2 DELIMS==" %%S IN ('FINDSTR "ServerUDPPort=" %PreferencesIni%') DO ^
SET ServerUdpPort=%%S
FOR /F "TOKENS=2 DELIMS==" %%P IN ('FINDSTR/B "PCPort=" %PreferencesIni%') DO ^
SET PeerCachePort=%%P
::
:: Find MobileMule port, based on that this is the last Port= occurrence
::
FOR /F "TOKENS=2 DELIMS==" %%M IN ('FINDSTR/B "Port=" %PreferencesIni%') DO ^
SET MobileMulePort=%%M
::
:: Find WebServer port, define MobileMule port first
::
FOR /F "TOKENS=2 DELIMS==" %%W IN ('FINDSTR/B "Port=" %PreferencesIni%') DO ^
IF NOT %MobileMulePort%==%%W SET WebServerPort=%%W
::
:: Filters MAC Address from IpConfig /All command, comma separated
:: needs delayed expansion - GetMac
::
FOR /F "TOKENS=2 DELIMS=:" %%T IN ('IPCONFIG/ALL^|FINDSTR
/ER /C:"[ ]..\-..\-..\-..\-..\-.."') DO SET TempMac=!TempMac!,%%T
::
:: Strip out all the spaces
::
SET TempMac=%TempMac: =%
::
:: Strip first comma, this is a bit lame to me, see GetIp
::
SET TempMac=%TempMac:~1%
::
:: Substitute dashes with colons
::
SET MacAddress=%TempMac:-=:%
::
:: Find gateway, this is the first occurrence after 0.0.0.0 in route output
::
FOR /F "TOKENS=3" %%G IN ('ROUTE PRINT ^|FINDSTR "\<0.0.0.0\>"') DO ^
SET Gateway=%%G
::
:: Filters Local IP Address from IpConfig /All command, needs delayed expansion
:: GetIp
::
FOR /F "TOKENS=2 DELIMS=:" %%I IN ('IPCONFIG
^|FIND "IP"
^|FINDSTR/V ":.*:"
') DO (
SET TempLocalIp=!TempLocalIp!,%%I
)
::
:: Strip out all the spaces
::
SET TempLocalIp=%TempLocalIp: =%
::
:: Strip first comma, this is a bit lame to me, see GetMac
::
SET LocalIp=%TempLocalIp:~1%
::
:: Print into Notepad
::
ECHO Computer=%COMPUTERNAME% Windows %WindowsVersion% %WindowsNumberOfBits%^
bit IP=%LocalIp% MAC=%MacAddress%^
TCP=%TcpPort% UDP=%UdpPort% Router= http://%Gateway%> %TMP%\eMuleData
NOTEPAD %TMP%\eMuleData
::
EXIT
::
:: License
::
Copyright (C) 2013-2014 Zangune
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
Zangune Nick@Host Nick=Zangune Host=Users.SourceForge.Net
http://sf.net/u/zangune