Netbios progam and other batch ideas!

Questions about programming languages and debugging
Post Reply

Did you find this good?

Yeah
1
50%
it was Ok i suppose
0
No votes
wtf it was crap!
0
No votes
what the hell is NETBIOS?
1
50%
 
Total votes: 2

elb0b0
Newbie
Newbie
Posts: 6
Joined: 11 Oct 2007, 16:00
16
Location: DLL HELL
Contact:

Netbios progam and other batch ideas!

Post by elb0b0 »

ok im new here, so you probly havent noticed me yet, heres my first tutorial on netbios batch programming, if its posted in the wrong place, soz mods!

Alright, I spent a lot of time figuring out NETBIOS latley, and I made a cool batch for it,

the cool thing about this batch is that its compatible with xp and vista!
now your probably thinking "what?!?"
well some commands on vista are not available on xp, like the timeout command,
so instead of changing the batch file so that a pause command was used instead
of a timeout command, I found a cool way to make it compatible, ok il stop talking and just show you!




Code: Select all

if exist %sysroot%\Windows\profiles goto microsucks_xp
if exist %sysroot%\Users goto microsucks_shitsta
goto start


:microsucks_xp
echo hey I see your using xp!? or nt? dont use vista its crap!
goto start

:microsucks_shitsta
echo I feel your pain dude... vista is useless...really is....
goto start


right, so if you understand even only a bit about batch files, you can see how it works,
it checks for a folder only xp or vista has, then sends the goto command to the relevant
commands..in the above its just used for a greeting in a batch, but I use it for more in
the NETBIOS program I made...
now theres a high chance that someone has figured this way of combatibility problem out before, but I havent seen it so I thought, hey I might as well stick it up on a thread!

okay so heres the NETBIOS program I made..... a bit too much echo's and not enough commands but I think its nice...

Code: Select all

@echo off
color 09
title \-/ Elbobo's program \-/ \-/ A nice little NETBIOS tool \-/

if exist %sysroot%\winnt goto microsucks_old
if exist %sysroot%\Windows\profiles goto microsucks_xp
if exist %sysroot%\Users goto microsucks_shitsta
goto start
:microsucks_old
echo your using a way old computer bud! linux might be up your street....
goto start

:microsucks_xp
echo hey I see your using xp!? or nt? dont use vista its crap!
goto start

:microsucks_shitsta
echo I feel your pain dude... vista is useless...really is....
goto start



:start
if exist %sysroot%\Windows\profiles goto nt1
if exist %sysroot%\winnt goto nt1
:nt1
if exist %sysroot%\Users goto v1
pause
goto nt2
:v1
timeout 3
:nt2
color 0c
cls
echo.
echo Bobs Network Basic Input Output System tool (NETBIOS)
echo.
echo.
echo.
echo.
echo Press 1 to do a NETBIOS "hack"
echo.
echo.
echo Press 2 to auto connect to a pre-edited connection (edit this batch)
echo.
echo.
echo Press 3 to go to my noobish websites..you can get my huge program there!
echo.
echo.
echo.


set /p gets= What do you wanna do?


if '%gets%'=='1' goto config
if '%gets%'=='2' goto main
if '%gets%'=='3' goto sites
if '%gets%'=='4' goto insult
if '%gets%'=='5' goto insult
if '%gets%'=='6' goto insult
if '%gets%'=='7' goto insult
if '%gets%'=='8' goto insult
if '%gets%'=='9' goto insult



cls
exit

:sites
if exist %sysroot%\Windows\profiles goto skid
if exist %sysroot%\winnt goto skid
if exist %sysroot%\Users goto skid_no_can_do


:skid
connect http://betahack.freewebpage.org
cls
goto start


:skid_no_can_do
echo sorry stupid vista has no connect command...
echo the url is http://betahack.freewebpage.org
pause
cls
goto start


:insult
cls
echo.
echo.
echo.
echo THERE ARE NO WINSHOES TO ACCOMPANY WINSOCKS YOU DOPE!
PAUSE
GOTO START


:main
color 0a
echo --------connecting..--------------------
echo.
echo.
echo.
net use K: \\169.254.112.139\C
rem /* you can change this ip to suit yours */

if exist %sysroot%\Windows\profiles goto nt3a
if exist %sysroot%\winnt goto nt3a
:nt3a
if exist %sysroot%\Users goto v2
pause
goto nt3b
:v2
timeout 5
:nt3b
cls
exit







:config
color 0a
cls
echo.
echo (tip! use ipconfig command on the other computer to get their ip address!)
echo.
echo.
echo.
set /p q= The Hosts I.P Address:
echo.
echo.
echo.
echo You will now see the NetBIOS Remote Machine Name Table...


if exist %sysroot%\Windows\profiles goto nt4
if exist %sysroot%\winnt goto nt4
:nt4
if exist %sysroot%\Users goto v3
pause
goto nt4b
:v3
timeout 3
:nt4b
nbtstat -a %q%
echo.
echo.
echo.
pause
echo.
echo.
echo you will now see the IP's shared resources....




if exist %sysroot%\Windows\profiles goto nt5
if exist %sysroot%\winnt goto nt5
:nt5
if exist %sysroot%\Users goto v4
pause
goto nt5b
:v4
timeout 3
:nt5b
echo.
echo.
echo.
net view %q%
echo.
echo.
echo.
pause
echo.
echo.
echo you will now be able to access the shared resources
echo you have seen above


if exist %sysroot%\Windows\profiles goto nt6
if exist %sysroot%\winnt goto nt6
:nt6
if exist %sysroot%\Users goto v5
pause
goto nt6b
:v5
timeout 3
:nt6b
echo.
echo.
echo What is the remote drive letter or Shared resource
echo you want to use? (e.g C , SharedDocs , Printer )
echo (dont type C:\ , just type C)
echo.
set /p w= drive letter/ shared resource:
echo.
echo.
echo Now what letter do you want this drive to represent? (try q!)
echo (as the above, type q)
set /p e= drive letter:
echo.
echo.
echo Okay im ready!! hold on!


if exist %sysroot%\Windows\profiles goto nt7
if exist %sysroot%\winnt goto nt7
:nt7
if exist %sysroot%\Users goto v6
pause
goto nt7b
:v6
timeout 1
:nt7b
cls
echo.
echo.
echo.
net use %e%: \\%q%\%w%
echo.
echo.
echo.
echo hope it worked!!! open My Computer to see if it did!
if exist %sysroot%\Windows\profiles goto nt8
if exist %sysroot%\winnt goto nt8
:nt8
if exist %sysroot%\Users goto v7
pause
goto nt8b
:v7
timeout 10
:nt8b
cls
exit




But hey, have you ever seen a really sqished up batch file?
The following does EXACTLY the same thing as the above batch,
but its half the size (when stored on disk) and it kinda looks cool..
i figured it out when I put the & symbol in an echo command, and
things messed up.
Its not that practical and its as easy as juggling fish when it comes to debugging,
but I still like it! kinda usefull for making a batch you dont want someone to figure out,
like my password batch, download the password batch here to see what I mean! (i reccomend not executing this batch because it requests a password, and if the password is wrong or not entered after 10 seconds your computer shuts down, and every time the computer is restarted it requests the password again! And the download isnt squished up so you can figure it out!)

http://betahack.freewebpage.org/logon.zip


some rules I learned when doing the & command what the following

-dont squish up goto commands, you can squish the "goto file" command, but not :file,
:file gets a line of its own.

- kinda like above, the "if exist" command gets its own line

- dont put & as a part of your echo command, or you'l get a syntax error,
e.g
echo this is Bob & johns batch
would result in something like:

this is Bob
"john" is not a recognised command blah blah blah..... (it wouldnt say blah blah of cource!)

you could do this
echo *******************&echo.&echo.&echo this is Bob + Johns batch&echo.&echo&echo ****************

that would look like

********************


this is Bob and Johns batch



********************

ok so instead of boring you with all my mad ideas for batch files, here's the squished up code...which is slightly less boring to some of you....!

Code: Select all

 @echo off&color 09&title \-/ Elbobo's program \-/ \-/ A nice little NETBIOS tool \-/&
if exist %sysroot%\winnt goto microsucks_old
if exist %sysroot%\Windows\profiles goto microsucks_xp
if exist %sysroot%\Users goto microsucks_shitsta
goto start
:microsucks_old
echo your using a way old computer bud! linux might be up your street....&goto start
:microsucks_xp
echo hey I see your using xp!? or nt? dont use vista its crap!&goto start
:microsucks_shitsta
echo I feel your pain dude... vista is useless...really is....&goto start
:start
if exist %sysroot%\Windows\profiles goto nt1&if exist %sysroot%\winnt goto nt1
:nt1
if exist %sysroot%\Users goto v1&pause&goto nt2
:v1
timeout 3
:nt2
color 0c&cls&echo.&echo Bobs Network Basic Input Output System tool (NETBIOS)&echo.&echo.&echo.&echo.&echo Press 1 to do a NETBIOS "hack"&echo.&echo.&echo Press 2 to auto connect to a pre-edited connection (edit this batch)&echo.&echo.&echo Press 3 to go to my noobish websites..you can get my huge program there!&echo.&echo.&echo.&set /p gets= What do you wanna do?
if '%gets%'=='1' goto config
if '%gets%'=='2' goto main
if '%gets%'=='3' goto sites
if '%gets%'=='4' goto insult
if '%gets%'=='5' goto insult
if '%gets%'=='6' goto insult
if '%gets%'=='7' goto insult
if '%gets%'=='8' goto insult
if '%gets%'=='9' goto insult
cls&exit
:sites
if exist %sysroot%\Windows\profiles goto skid&if exist %sysroot%\winnt goto skid&if exist %sysroot%\Users goto skid_no_can_do
:skid
connect http://betahack.freewebpage.org&cls&goto start
:skid_no_can_do
echo sorry stupid vista has no connect command...&echo the url is http://betahack.freewebpage.org&pause&cls&goto start
:insult
cls&echo.&echo.&echo.&echo THERE ARE NO WINSHOES TO ACCOMPANY WINSOCKS YOU DOPE!&PAUSE
GOTO START
:main
color 0a&echo --------connecting..--------------------&echo.&echo.&echo.
net use K: \\169.254.112.139\C
rem /* you can change this ip to suit yours */
if exist %sysroot%\Windows\profiles goto nt3a&if exist %sysroot%\winnt goto nt3a
:nt3a
if exist %sysroot%\Users goto v2&pause&goto nt3b
:v2
timeout 5
:nt3b
cls&exit
:config
color 0a&cls &echo.&echo (tip! use ipconfig command on the other computer to get their ip address!)&echo.&echo.&echo.&set /p q= The Hosts I.P Address:&echo.&echo.&echo.&echo You will now see the NetBIOS Remote Machine Name Table...&if exist %sysroot%\Windows\profiles goto nt4&if exist %sysroot%\winnt goto nt4
:nt4
if exist %sysroot%\Users goto v3&pause
goto nt4b
:v3
timeout 3
:nt4b
nbtstat -a %q%&echo.&echo.&echo.&pause&echo.&echo.&echo you will now see the IP's shared resources....&if exist %sysroot%\Windows\profiles goto nt5&if exist %sysroot%\winnt goto nt5
:nt5
if exist %sysroot%\Users goto v4&pause&goto nt5b
:v4
timeout 3
:nt5b
echo.&echo.&echo.
net view %q%&echo.&echo.&echo.&pause&echo.&echo.&echo you will now be able to access the shared resources &echo you have seen above&if exist %sysroot%\Windows\profiles goto nt6&if exist %sysroot%\winnt goto nt6
:nt6
if exist %sysroot%\Users goto v5&pause&goto nt6b
:v5
timeout 3
:nt6b
echo.&echo.&echo What is the remote drive letter or Shared resource &echo you want to use? (e.g C , SharedDocs , Printer ) &echo (dont type C:\ , just type C)&echo.&set /p w= drive letter/ shared resource:&echo.&echo.&echo Now what letter do you want this drive to represent? (try q!) &echo (as the above, type q)&set /p e= drive letter:&echo.&echo.&echo Okay im ready!! hold on!&if exist %sysroot%\Windows\profiles goto nt7&if exist %sysroot%\winnt goto nt7
:nt7
if exist %sysroot%\Users goto v6&pause&goto nt7b
:v6
timeout 1
:nt7b
cls&echo.&echo.&echo.&net use %e%: \\%q%\%w%&echo.&echo.&echo.&echo hope it worked!!! open My Computer to see if it did!&if exist %sysroot%\Windows\profiles goto nt8&if exist %sysroot%\winnt goto nt8
:nt8
if exist %sysroot%\Users goto v7&pause&goto nt8b
:v7
timeout 10
:nt8b
cls&exit
******************************************
-------------------------------
some NETBIOS info...
-------------------------------
******************************************
The Network Basic Input Output System is also known as NetBIOS. NetBIOS was originally developed by IBM, which used Sytek as an Application Programming Interface (API) for the client software operation systems. These systems included Windows98, Windows Me, Windows NT.




----------------------------
ports
----------------------------
X137 NETBIOS Name Service
_138 NETBIOS Datagram Service
_139 NETBIOS Session Service


----------------------------
commands
----------------------------
NBTSTAT [-a RemoteName] [-A IP address] [-c] [-n][-r] [-R] [-s] [interval] ]



NBTSTAT -a (adapter status) Lists the remote machine's name table given its name

NBTSTAT -A (Adapter status) Lists the remote machine's name table given its IP address.

NBTSTAT -c (cache) Lists the remote name cache including the IP addresses

NBTSTAT -n (names) Lists local NetBIOS names.

NBTSTAT -r (resolved) Lists names resolved by broadcast and via WINS

NBTSTAT -R (Reload) Purges and reloads the remote cache name table

NBTSTAT -S (Sessions) Lists sessions table with the destination IP addresses

NBTSTAT -s (sessions) Lists sessions table converting destination IP addresses to host names.

-------------------------------------------
Example On How To Use the NBTSTAT Command:
-------------------------------------------

_________________________________________
C:\WINDOWS>NBTSTAT –a 169.254.112.139



NetBIOS Remote Machine Name Table



Name Type Status

--------------------------------------------------------------------------

test_share <00> UNIQUE Registered

WORKGROUP <00> GROUP Registered

test_share <20> UNIQUE Registered

INet~Services <1C> GROUP Registered

(note the number 20 indicated file and printer sharing is active)


________________________________________
C:\>net view 169.254.112.139

C:\>net view \\test_share



Shared Resources At 169.254.112.139



Share Name Type

-------------------------------------------------

NETLOGON DISK
test_share DISK
TEST DISK


(shares called admin$, C$ and ipc$ are hidden, I think the $ symbol at the end of a shared resource makes it hidden...if im wrong tell me)


___________________________________________
Finaly, to use that share...
C:\net use x: \\169.254.112.139\test_share
____________________________________________
(the x can be changed, to any free drive letter, you have to pick a different letter if x is in use, also, just open up my computer and the drive will be there for you to browse..)



ok thats all for now, but if you want to check out my other batch files you can download a lot of them at http://betahack.freewebpage.org/batchfiles_set.zip

Theres my huge batch program on it, and its a really quick download..!
i spent countless hours of my life at these batch files, I even fell asleep at school as a result



IF anyone else knows cool batch file tricks drop them in a comment! [/code]

Post Reply