Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Ok guys, I'm gonna cry soon.
I've tried this for a long time. And i know theres gonna be an easy solution & it's gonna be so simple.. I just can't figure it out.Right i'll try keep it simple.
I'm creating a fake hacking simulation game in batch.
I have a "connect" command and a "netstat" command.
I want the user to type connect first, so they connect to something. Then they will have to use the Netstat command to view IP's and ports.But the user can completely skip the connect part and go straight into netstat and view the IP.
I want it so if they type Netstat, it displays some IP's
And ONLY when they connect. It displays those IP's but with an added IP (which will be the IP that they connected too)so it simulates how to gain the IP of a website.
I know it's not real...No comments about it, it's just a game i'm creating.My idea is, When someone does the command to connect to a website. It sets some variable. Then when they do the Netstat command, it checks to see if that variable has been set.
I tried this but i couldn't get it to work. Hope you guys have some ideas.Sorry if it makes no sence, It's really hard to explain what i want.
***************************
Need BatchFile Help ?
Msg me :)
***************************

In your connect routine add
set connectcheck=1
Then as the first portion of your netstat routine add
IF %connectcheck% NEQ 1 goto connecterrorAdd a connecterror variable that says something like
:connecterror
Echo No current network connection - please check your network connection
GOTO Connect
A little hard to be sure this lines up with what you're doing without actually seeing the code, but this should hopefully get you where you're trying to get.

Thanks, i shall try this.
This is something i've never come across before so i shall try it.
Thanks for the help!***************************
Need BatchFile Help ?
Msg me :)
***************************

Ok. so i have added that code. If i type Connect-www.fakeomail.com
It works, Then when i type Netstat It goes to NETSTAT and displays what i want it to display. If i run the batch file again, but this time NOT connect first. I type Netstat the program just quits.
My guess is that its checking the variable that hasn't been set yet. So it's checking basically..Nothing, I'm messing around with it currently, any help will be grateful.
BOLD = Important parts
:MISSION1START
echo ****************
echo * Hack-o-matic *
echo ****************
echo.
SET /p Command=Command:
IF %Command% == Connect Goto CONNECTERROR
IF %Command% == Netstat Goto NETSTAT
IF %Command% == Shutdown Goto SHUTDOWNERROR
IF %Command% == Connect-www.fakeomail.com Goto CONNECTED
Goto SYNTAXERROR:CONNECTED
set connectcheck=1
CLS
echo Connection Established with Http://www.Fakeomail.com
Goto MISSION1START:NETSTAT
IF %connectcheck% NEQ 1 goto NETSTAT2
CLS
echo.
echo Active Connections
echo.
echo Proto Local Address Foreign Address State
echo TCP 127.0.0.1:2830 127.0.0.1:2831 ESTABLISHED
echo TCP 127.0.0.1:2831 127.0.0.1:2830 ESTABLISHED
echo TCP 127.0.0.1:4848 127.0.0.1:4849 ESTABLISHED
echo TCP 127.0.0.1:4849 127.0.0.1:4848 ESTABLISHED
echo TCP 127.0.0.1:4851 127.0.0.1:4852 ESTABLISHED
echo TCP 127.0.0.1:4852 127.0.0.1:4851 ESTABLISHED
echo TCP 192.168.1.33:1436 64.12.152.132:80 ESTABLISHED
echo TCP 192.168.1.33:1553 194.242.197.144:80 CLOSE_WAIT
echo TCP 192.168.1.33:2766 67.54.189.103:1863 ESTABLISHED
Pause:NETSTAT2
CLS
echo.
echo Active Connections
echo.
echo Proto Local Address Foreign Address State
echo TCP 127.0.0.1:2830 127.0.0.1:2831 ESTABLISHED
echo TCP 127.0.0.1:2831 127.0.0.1:2830 ESTABLISHED
echo TCP 127.0.0.1:4848 127.0.0.1:4849 ESTABLISHED
echo TCP 127.0.0.1:4849 127.0.0.1:4848 ESTABLISHED
echo TCP 127.0.0.1:4851 127.0.0.1:4852 ESTABLISHED
echo TCP 127.0.0.1:4852 127.0.0.1:4851 ESTABLISHED
echo TCP 192.168.1.33:1553 194.242.197.144:80 CLOSE_WAIT
echo TCP 192.168.1.33:2766 67.54.189.103:1863 ESTABLISHED
Pause
goto MISSION1START:CONNECTERROR
CLS
echo.
echo Nothing to connect too!
Pause
Goto MISSION1START***************************
Need BatchFile Help ?
Msg me :)
***************************

I think you're probably spot on with your guess, in that case - let's set the connectcheck variable before we do anything else.
:PRESET
Set connectcheck=0:MISSION1START
echo ****************
echo * Hack-o-matic *
echo ****************
echo.
SET /p Command=Command:
IF %Command% == Connect Goto CONNECTERROR
IF %Command% == Netstat Goto NETSTAT
IF %Command% == Shutdown Goto SHUTDOWNERROR
IF %Command% == Connect-www.fakeomail.com Goto CONNECTED
Goto SYNTAXERROR:CONNECTED
set connectcheck=1
CLS
echo Connection Established with Http://www.Fakeomail.com
Goto MISSION1START:NETSTAT
IF %connectcheck% NEQ 1 goto NETSTAT2
CLS
echo.
echo Active Connections
echo.
echo Proto Local Address Foreign Address State
echo TCP 127.0.0.1:2830 127.0.0.1:2831 ESTABLISHED
echo TCP 127.0.0.1:2831 127.0.0.1:2830 ESTABLISHED
echo TCP 127.0.0.1:4848 127.0.0.1:4849 ESTABLISHED
echo TCP 127.0.0.1:4849 127.0.0.1:4848 ESTABLISHED
echo TCP 127.0.0.1:4851 127.0.0.1:4852 ESTABLISHED
echo TCP 127.0.0.1:4852 127.0.0.1:4851 ESTABLISHED
echo TCP 192.168.1.33:1436 64.12.152.132:80 ESTABLISHED
echo TCP 192.168.1.33:1553 194.242.197.144:80 CLOSE_WAIT
echo TCP 192.168.1.33:2766 67.54.189.103:1863 ESTABLISHED
Pause:NETSTAT2
CLS
echo.
echo Active Connections
echo.
echo Proto Local Address Foreign Address State
echo TCP 127.0.0.1:2830 127.0.0.1:2831 ESTABLISHED
echo TCP 127.0.0.1:2831 127.0.0.1:2830 ESTABLISHED
echo TCP 127.0.0.1:4848 127.0.0.1:4849 ESTABLISHED
echo TCP 127.0.0.1:4849 127.0.0.1:4848 ESTABLISHED
echo TCP 127.0.0.1:4851 127.0.0.1:4852 ESTABLISHED
echo TCP 127.0.0.1:4852 127.0.0.1:4851 ESTABLISHED
echo TCP 192.168.1.33:1553 194.242.197.144:80 CLOSE_WAIT
echo TCP 192.168.1.33:2766 67.54.189.103:1863 ESTABLISHED
Pause
goto MISSION1START:CONNECTERROR
CLS
echo.
echo Nothing to connect too!
Pause
Goto MISSION1START

That looks promising now!
I'll try it Tomorrow.
Thanks for that help m8 !***************************
Need BatchFile Help ?
Msg me :)
***************************

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |