China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-24 06:22
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » So many experts, who can write a program to scan the internal network IP and mac! View 7,344 Replies 51
Floor 16 Posted 2006-12-29 05:56 ·  中国 湖北 荆门 电信
初级用户
Credits 36
Posts 15
Joined 2006-11-20 10:44
19-year member
UID 71131
Gender Male
Status Offline
The result of this test which took 10 minutes (the batch file seems to still be running):
list.txt
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
00-0A-EB-F9-0F-F4
------------192.168.0.28
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
==================================
Strange, only one IP and MAC were scanned
[ Last edited by ygzxw on 2006-12-28 at 04:58 PM ]
Floor 17 Posted 2006-12-29 06:02 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

@echo off
set/p=>list.txt<nul
for /l %%a in (1,1,254) do (
echo.&echo.
for /f "delims== tokens=2" %%i in ('nbtstat -A 192.168.0.%%a^|find "MAC Address"') do (
echo==========================>>list.txt
echo %%i=======192.168.0.%%a >>list.txt
)
)
pause
start list.txt
goto :eof
Floor 18 Posted 2006-12-29 06:03 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  Could it be that your internal network host has some restrictions? I tested and my own can get results.
Floor 19 Posted 2006-12-29 06:12 ·  中国 湖北 荆门 电信
初级用户
Credits 36
Posts 15
Joined 2006-11-20 10:44
19-year member
UID 71131
Gender Male
Status Offline
My computer has no restrictions at all! This local area network, I am the network administrator!!!!!

[ Last edited by ygzxw on 2006-12-28 at 05:15 PM ]
Floor 20 Posted 2006-12-29 06:18 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  Then take any intranet IP to test, for example: nbtstat -a 192.168.0.24, see what the result is?
Floor 21 Posted 2006-12-29 06:36 ·  中国 北京 联通
银牌会员
★★★
努力做坏人
Credits 1,185
Posts 438
Joined 2006-08-28 12:00
19-year member
UID 61449
From 北京
Status Offline
```
@echo off
arp -d
for /l %%i in (0,1,128) do ping 192.168.1.%%i -n 1 >nul
arp -a >11.txt
arp -d
for /l %%i in (128,1,255) do ping 192.168.1.%%i -n 1 >nul
arp -a >>11.txt
arp -d
```
我今后在论坛的目标就是做个超级坏人!!!
Floor 22 Posted 2006-12-29 06:36 ·  中国 湖北 荆门 电信
初级用户
Credits 36
Posts 15
Joined 2006-11-20 10:44
19-year member
UID 71131
Gender Male
Status Offline
CODE:
--------------------------------------------------------------------------------

@echo off
set/p=>list.txt<nul
for /l %%a in (1,1,254) do (
echo.&echo.
for /f "delims== tokens=2" %%i in ('nbtstat -A 192.168.0.%%a^|find "MAC Address"') do (
echo==========================>>list.txt
echo %%i=======192.168.0.%%a >>list.txt
)
)
pause
start list.txt
goto :eof

Now it's okay, but it's extremely slow!!!!

Test results:
=========================
00-0A-EB-F9-0F-**
=======192.168.0.28
=========================
00-05-5D-5D-A0-**
=======192.168.0.60
=========================
00-E0-4C-C4-3E-**
=======192.168.0.63
=========================
00-0A-EB-6F-4E-**
=======192.168.0.65
=========================
00-0A-EB-F9-0F-**
=======192.168.0.66

[ Last edited by ygzxw on 2006-12-28 at 05:47 PM ]
Floor 23 Posted 2006-12-29 06:57 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

The main reason for the slow speed is the delay caused by the nbtstat command detecting inactive IPs.
Floor 24 Posted 2006-12-29 07:10 ·  中国 湖北 荆门 电信
初级用户
Credits 36
Posts 15
Joined 2006-11-20 10:44
19-year member
UID 71131
Gender Male
Status Offline
I understand, thank you!
Floor 25 Posted 2006-12-29 07:27 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Oh no, I taught the technology to the Japanese.
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 26 Posted 2006-12-29 07:34 ·  中国 山西 运城 联通
银牌会员
★★★
天的白色影子
Credits 2,343
Posts 636
Joined 2004-03-06 00:00
22-year member
UID 19350
Gender Male
Status Offline
Scanning MAC without nbtstat

Using ping -n 1 -w 10 IP first, then arp -a | find "IP" is a better solution

Because using ping can quickly detect the connection

Command line solution

for /l %l in (1,1,254) do @(ping -n 1 -w 10 192.168.0.%l>nul && arp -a | find " 192.168.0.%l ")
Floor 27 Posted 2006-12-29 07:46 ·  中国 山西 运城 联通
银牌会员
★★★
天的白色影子
Credits 2,343
Posts 636
Joined 2004-03-06 00:00
22-year member
UID 19350
Gender Male
Status Offline
Sorry, just saw the plan of 9527, mine is invalid.

I don't know how large the ARP table of WIN can be?
Floor 28 Posted 2006-12-29 07:54 ·  中国 北京 朝阳区 联通
高级用户
★★
朦胧的世界
Credits 579
Posts 218
Joined 2006-10-24 04:29
19-year member
UID 67972
Status Offline
In fact, the MAC table obtained by relying on IP with batch processing commands cannot guarantee authenticity.

认识自己,降伏自己,改变自己
,才能改变别人!
Floor 29 Posted 2006-12-30 23:25 ·  中国 山东 济南 电信
社区乞丐
★★
此图片另存后死机
Credits -49
Posts 90
Joined 2006-12-02 13:00
19-year member
UID 72412
Gender Male
Status Offline
re lxmxn
-----------------------
Obtain the "computer name" list using net view
Obtain MAC using nbtstat -a "computer name"
------------------------



@ECHO %dbg% OFF
setlocal ENABLEDELAYEDEXPANSION

for /f "tokens=1" %%i in ('net view') do (
SET COMPUTERNAME=%%i
CALL :CNAME
)


:CNAME
IF NOT %COMPUTERNAME:~0,2%==\\ GOTO :EOF
SET COMPUTERNAME=%COMPUTERNAME:~2%
FOR /F "skip=1 tokens=4" %%j in ('nbtstat -a %COMPUTERNAME%^|FINDSTR /I MAC') do (
ECHO %COMPUTERNAME% %%j
)
GOTO :EOF



[ Last edited by tghksj on 2006-12-30 at 12:34 PM ]
Floor 30 Posted 2006-12-31 00:43 ·  中国 广东 深圳 电信
初级用户
Credits 32
Posts 16
Joined 2006-10-19 21:11
19-year member
UID 66985
Gender Male
Status Offline
Batch processing also requires the support of system services.
For example, in my company's local area network, all are single - machine Internet access, no sharing is needed, the Server service is not even started, and it accesses the Internet through a router, with DHCP automatically obtaining the IP. In this case, I think this batch processing has no use.
Forum Jump: