bash随笔
bash
for i in `ls *.txt`; do mv $i ${i%.txt}.md; done
bash
echo '127.0.0.1' | sed -n '/[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+/p'
bash
find / | grep -vE "要搜的字符" nasm .txt gcc
bash
cd /usr/include && grep -r socklen_t * | grep typedef
find ../ | grep -e "netinet/in.h"
bash
awk '{ sum += $1 }; END { print sum }' filename
awk -F: '{ print $1 }' | cat /etc/passwd
bash
for i in `curl <url> | tr -cs '[:alnum:]' ' ' | sort -u`;
do
echo $i >> <filename>;
done
bash
find -maxdepth 1 -type f -exec file {} \; | awk -F: '{print $2}' | sort | uniq -c
bash
url="<url>"
curl url | grep -Eo 'href="[^\"]+"' | sed 's/href=//; s/\"//g' | while read line; do
if [[ $line == /* ]] || [[ $line =~ ^https?:// ]]; then
echo $line
else
echo "${url}${line}"
fi
done
bash
1.先建个c语言file
`echo -e "#include <stdio.h>\nint main(){\n\tprintf("hello world");\n\treturn 0;\n}" >> hello.c`
2.gcc hello.c -o hello -print-search-dirs >> print-search-dirs.txt
3.cat print-search-dirs.txt | tr [:alnum:] "0" /*replace*/
4.cat print-search-dirs.txt | sed 's/:/\n/g1'
bash
nc -lvp 666
bash
echo -e "import os\nimport socket\nmsg=os.listdir()\ns=socket.socket()\n
IP=input(\"please ip address:\")\nPort=input(\"please port:\")\ns.connect((IP,int(Port)))\ns.send(\"Connection is normal\".encode(\"utf-8\"))\nmsg=s.recv(1024)\nprint(msg)\n" >> shell.py | echo -e '\e[31;5msuccessful!\e[0m'
bash
1.gcc -c elfDemo.c -o elfDemo.rel
2.readelf -h elfDemo.rel | grep /*-i "magic"*/ /*想加就去掉/**/看看吧*/
3.find ../../usr/include/ | grep -e "elf.h">> elf_path.txt /*搜索后重定向输入到elf_path.txt中*/
/*进vi elf_path.txt 看看,输入 :set nu 有几行file_path就查看哪一行的数字*/
4.vi $(sed -n '数字p' elfh_path.txt) /*也可自行加到shell 动态输入 read -p"请输入要查看的file_path的行数index值 */不说了说的多了^.^
sed -n '308,332p' $(sed -n "2p" elfh.txt) >> elf_struct.txt
#!/bin/bash
show(){
read -p $'\e[32mplease intput fileanme:\e[0m' -a filename
cat -n $filename | grep --color=always -E "^ *[0-9]+|$"
}
while true; do
show $filename
# Read the line number input from the user
read -p $'\e[32mPlease enter the line number to view (or type \e[31m\'exit\'\e[32m to quit):\e[0m ' line_number
# Check if the user wants to exit
if [ "$line_number" == "exit" ]; then
echo -e "\e[31;5mExiting the script.\e[0m"
break
fi
# Use the awk command to get the file path for the specified line number
file_path=$(awk -v line="$line_number" 'NR == line {print}' $filename)
# Check if the file path is empty
if [ -z "$file_path" ]; then
echo -e "\e[31;5mFile path for the specified line number was not found.\e[0m"
else
# Open the file using vi
vi "$file_path"
fi
done
bash
#DoMainNameQuery.sh
#!/bin/bash
read -p $'\e[32mplease input check domain (Usage: input (baidu.com)):\e[0m' domain
target=${domain%.com}
# 在生成文件之前检查文件是否存在,如果存在则删除
if [ -e "${target}/${target}.txt" ]; then
rm "${target}/${target}.txt"
fi
if [ -e "${target}/${target}_ip.txt" ]; then
rm "${target}/${target}_ip.txt"
fi
if [ -e "${target}/scan_results.xml" ]; then
rm "${target}/scan_results.xml"
fi
mkdir "$target"
echo -e "\e[31;5mplease wait for a moment, program running...\e[0m"
dnsrecon -d "$domain" >> "${target}/${target}.txt"
grep -E -o "([0-9]{1,3}\.){3}[0-9]{1,3}" "${target}/${target}.txt" | sort -u >> "${target}/${target}_ip.txt"
echo -e "\e[31msave file as ${target}/${target}_ip.txt.\e[0m"
total_lines=$(wc -l < "${target}/${target}_ip.txt")
total_lines_colored="\e[31m$total_lines\e[0m"
echo -e "file total lines is :$total_lines_colored"
cat -n "${target}/${target}_ip.txt" | GREP_COLORS='mt=1;32' grep --color=always -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | awk '{printf "\033[31m%s\033[0m \x1b[32m%s\x1b[0m\n", $1, $2}'
nmap -iL "${target}/${target}_ip.txt" -p 80,443 -oX "${target}/scan_results.xml"
cat "${target}/scan_results.xml" | GREP_COLORS='mt=1;34' grep --color=always "open"
bash
gcc -v --help >> gcc_help.md 进vi gcc_help.md看看:set nu
vi的正则表达式搜 输入:%s/-fPIC
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具