查看文件
- (1) cat 适合查看小文件
cat /etc/snort/snort.conf
- (2) head 查看文件的头部 默认显示文件的前10行
head /etc/snort/snort .conf
head -20 /etc/snort/snort.conf//显示文件的前20行
- (3)显示文件的尾部
tail 默认显示文件的后10行
-f, 随文件增长即时输出新增数据;(用于监视一个文件的变化)
- (4) Numbering the Lines,nl 显示文件的行号(不显示空白行)
nl /etc/snort/snort.conf ==
cat -b /etc/snort/snort.conf
wc -l /etc/snort/snort.conf //统计文件的行数(空行也进行编号)
cat -n /etc/snort/snort.conf(空行也进行编号)
- (5) Filtering Text with grep使用grep做文本过滤
cat /etc/snort/snort.conf l grep output
- (6)挑战
cat -n /etc/snort/snort.confgrep output
cat -n /etc/snort/snort.confhead -544 tail -9
- (7) 挑战2
只查看number.txt文件(共100行) 内第20到第30行的内容
seq 1 100 > number.txt方法1:head -30 number.txt tail -11
方法2:
tail +20 number.txt head -11tail -81 number.txt head -11
使用sed 查找和替换
文本三剑客
grep 过滤
sed 编辑
awk 截取
非交互式 流 编辑器
sed中的命令:
l)s---替换
2)g--全局替换
s/old/new/ 用new替换成old
┌──(root㉿kali)-[~/work/exam]
└─# echo 'HI Depressiom nihao'
HI Depressiom nihao
┌──(root㉿kali)-[~/work/exam]
└─# echo 'HI Depressiom nihao' | sed 's#nihao # hahah'
sed:-e 表达式 #1,字符 15:未终止的“s”命令
┌──(root㉿kali)-[~/work/exam]
└─# echo 'HI Depressiom nihao' | sed 's#nihao # hahah#'
HI Depressiom nihao
┌──(root㉿kali)-[~/work/exam]
└─# echo 'HI Depressiom nihao' | sed 's#nihao#hahah#'
HI Depressiom hahah
┌──(root㉿kali)-[~/work/exam] # 默认替换第一个
└─# echo 'HI nihao, Depressiom nihao' | sed 's#nihao#hahah#'
HI hahah, Depressiom nihao
┌──(root㉿kali)-[~/work/exam] # g 全局替换
└─# echo 'HI nihao, Depressiom nihao' | sed 's#nihao#hahah#g'
HI hahah, Depressiom hahah
┌──(root㉿kali)-[~/work/exam]# 2 替换出现的第二个字符
└─# echo 'HI nihao, Depressiom nihao' | sed 's#nihao#hahah#2'
HI nihao, Depressiom hahah
┌──(root㉿kali)-[~/work/exam] # 替换只针对一行中出现多个要替换的字符
└─# sed 's/mysql/Mysql/' /etc/mysql/my.cnf > my2.cnf
┌──(root㉿kali)-[~/work/exam]
└─# ls
my2.cnf
┌──(root㉿kali)-[~/work/exam]
└─# cat my2.cnf
# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 0. "/etc/Mysql/my.cnf" symlinks to this file, reason why all the rest is read.
# 1. "/etc/Mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/Mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/Mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
┌──(root㉿kali)-[~/work/exam]
└─# grep mysql my2.cnf
socket = /run/Mysqld/mysqld.sock
┌──(root㉿kali)-[~/work/exam]
└─# grep -i mysql my2.cnf
# The MariaDB/MySQL tools read configuration files in the following order:
# 0. "/etc/Mysql/my.cnf" symlinks to this file, reason why all the rest is read.
# 1. "/etc/Mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/Mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/Mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
socket = /run/Mysqld/mysqld.sock
!includedir /etc/Mysql/conf.d/
!includedir /etc/Mysql/mariadb.conf.d/
使用more 和 less 查看文件
more
回车--向下显示一行
空格--向下显示一屏
Pageup--向上翻页
Pagedown--向下翻页
q -- 退出
/关键字 按关键字查找(找到之后继续查找,可以使用n)
! + 命令 -- 调用命令执行
!/bin/bash 调用一个shell执行,(会用这种方法进行shell逃逸)
v -- 进入vi编辑界面
──(root㉿kali)-[~/work/exam]
└─# more my2.cnf
# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 0. "/etc/Mysql/my.cnf" symlinks to this file, reason why all the rest is read.
# 1. "/etc/Mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/Mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/Mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# If you are new to MariaDB, check out https://mariadb.com/kb/en/basic-mariadb-artic
les/
#
# This group is read both by the client and the server
# use it for options that affect everything
#
--More--(79%)
┌──(root㉿kali)-[~/work/exam]
└─# more my2.cnf
# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 0. "/etc/Mysql/my.cnf" symlinks to this file, reason why all the rest is read.
# 1. "/etc/Mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/Mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/Mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# If you are new to MariaDB, check out https://mariadb.com/kb/en/basic-mariadb-artic
les/
#
# This group is read both by the client and the server
# use it for options that affect everything
#
!ls
my2.cnf
------------------------
/usr/bin/vi -c 1 my2.cnf------------------------
!/bin/bash
┌──(root㉿kali)-[~/work/exam]
└─# ls /root
hackingskills work
┌──(root㉿kali)-[~/work/exam]
└─# exit
exit
------------------------
[client-server]
# Port or socket location where to connect
# port = 3306
socket = /run/Mysqld/mysqld.sock
# Import all .cnf files from configuration directory
!includedir /etc/Mysql/conf.d/
!includedir /etc/Mysql/mariadb.conf.d/
less is more
光标的快速反应
-N -- 打开文件直接显示行号
!includedir /etc/Mysql/conf.d/
[ 行 19/30 (63%),列 2/56 ( 3%),字符 796/1127 (70%) ]
^G 帮助 ^O 写入 ^W 搜索 ^K 剪切 ^T 执行命令 ^C 位置
^X 离开 ^R 读档 ^\ 替换 ^U 粘贴 ^J 对齐 ^/ 跳行
文本处理练习
/usr/share/wordlists -- Kali中常用的(口令)字典文件的位置
┌──(root㉿kali)-[~]
└─# cd /usr/share/wordlists/metasploit
┌──(root㉿kali)-[/usr/share/wordlists/metasploit]
└─# ls
adobe_top100_pass.txt namelist.txt
av_hips_executables.txt oracle_default_hashes.txt
av-update-urls.txt oracle_default_passwords.csv
burnett_top_1024.txt oracle_default_userpass.txt
burnett_top_500.txt password.lst
can_flood_frames.txt piata_ssh_userpass.txt
cms400net_default_userpass.txt postgres_default_pass.txt
common_roots.txt postgres_default_userpass.txt
dangerzone_a.txt postgres_default_user.txt
dangerzone_b.txt root_userpass.txt
db2_default_pass.txt routers_userpass.txt
db2_default_userpass.txt rpc_names.txt
db2_default_user.txt rservices_from_users.txt
default_pass_for_services_unhash.txt sap_common.txt
default_userpass_for_services_unhash.txt sap_default.txt
default_users_for_services_unhash.txt sap_icm_paths.txt
dlink_telnet_backdoor_userpass.txt scada_default_userpass.txt
grafana_plugins.txt sensitive_files.txt
hci_oracle_passwords.csv sensitive_files_win.txt
http_default_pass.txt sid.txt
http_default_userpass.txt snmp_default_pass.txt
http_default_users.txt telerik_ui_asp_net_ajax_versions.txt
http_owa_common.txt telnet_cdata_ftth_backdoor_userpass.txt
idrac_default_pass.txt tftp.txt
idrac_default_user.txt tomcat_mgr_default_pass.txt
ipmi_passwords.txt tomcat_mgr_default_userpass.txt
ipmi_users.txt tomcat_mgr_default_users.txt
joomla.txt unix_passwords.txt
keyboard-patterns.txt unix_users.txt
lync_subdomains.txt vnc_passwords.txt
malicious_urls.txt vxworks_collide_20.txt
mirai_pass.txt vxworks_common_20.txt
mirai_user_pass.txt wp-exploitable-plugins.txt
mirai_user.txt wp-exploitable-themes.txt
multi_vendor_cctv_dvr_pass.txt wp-plugins.txt
multi_vendor_cctv_dvr_users.txt wp-themes.txt
named_pipes.txt
┌──(root㉿kali)-[/usr/share/wordlists/metasploit]
└─# ls *lst
password.lst
┌──(root㉿kali)-[/usr/share/wordlists/metasploit]
└─# ls -ln password.lst
-rw-r--r-- 1 0 0 820674 7月28日 00:11 password.lst
┌──(root㉿kali)-[/usr/share/wordlists/metasploit]
└─# more password.lst
┌──(root㉿kali)-[/usr/share/wordlists/metasploit]
└─# less password.lst
┌──(root㉿kali)-[/usr/share/wordlists/metasploit]
└─# wc -l password.lst
88398 password.lst
──(root㉿kali)-[/usr/share/wordlists/metasploit]
└─# tail -20 password.lst
zxcvbnm
zydeco
zygote
zygotic
zymurgy
zyrtec
zyuganov
zzz
zürich
Ågar
Ångström
éclair
éclairs
éclat
élan
émigré
émigrés
épée
étude
vagrant
┌──(root㉿kali)-[/usr/share/wordlists/metasploit]
└─# cat password.lst | grep 123
123
123123
123321
1234
12345
123456
1234567
12345678
123456789
1234567890
1234qwer
123abc
123go
123qwe
a12345
abc123
abcd123
abcd1234
aki123
asdf1234
chris123
happy123
hello123
help123
jkl123
red123
test123
xxx123
xyz123
zxc123
本文来自博客园,作者:depressiom,转载请注明原文链接:https://www.cnblogs.com/depressiom/p/17669195.html