kali linux 2016 使用指南(二)

虚拟机安装增强

1.Kali 官方安装

更新 /etc/apt/sources.list

你所添加的源,请确保是我在一中写的所有

然后在线安装增强功能

1
2
3
4
5
apt-get update

apt-get install -y virtualbox-guest-x11

reboot
2.VirtualBox自带包安装
1
2
3
4
5
6
7
8
9
apt-get update && apt-get install -y linux-headers-$(uname-r)

cp /media/cd-rom/VBoxLinuxAdditions.run /root/

chmod 755 /root/VBoxLinuxAdditions.run

cd/root

./VBoxLinuxAdditions.run

内核头有问题自己手动安装过程

打开 http://http.kali.org/kali/pool/main/l/linux/

下载对应自己内核版本的 linux-kbuild

1
2
3
4
5
6
7
8
9
10
11
12
13
wget http://http.kali.org/kali/pool/main/l/linux/linux-kbuild-4.6_4.6.4-1kali1_amd64.deb

dpkg -i linux-kbuild-4.6_4.6.4-1kali1_amd64.deb

wget http://http.kali.org/kali/pool/main/l/linux/linux-headers-4.6.0-kali1-common_4.6.4-1kali1_amd64.deb

wget http://http.kali.org/kali/pool/main/l/linux/http://http.kali.org/kali/pool/main/l/linux/linux-headers-4.6.0-kali1-amd64_4.6.4-1kali1_amd64.deb

dpkg -i linux-headers-4.6.0-kali1-common_4.6.4-1kali1_amd64.deb

dpkg -i linux-headers-4.6.0-kali1-amd64_4.6.4-1kali1_amd64.deb

apt-get -f install

开启SSH服务

首先:编辑sshd_config文件

1
vim /etc/ssh/sshd_config

其次:将sshd_config文件中的语句PermitRootLogin prohibit-password修改为:

1
PermitRootLogin yes

再次:使用命令启动SSH服务:

1
2
3
/etc/init.d/ssh start
# 或者
service ssh start

最后:设置系统开机自动启动SSH服务:

1
update-rc.d ssh enable  //系统自动启动SSH服务

mysql重置密码

1、如果Linux中未安装MySQL,则需要下载安装,在安装的过程中会要求输入用户名密码,则无需重置,直接设置

2、MySQL设置UTF-8编码格式**

配置文件:

1
root@kali:~# vim /etc/mysql/my.cnf

添加默认utf-8编码:

1
2
3
4
5
6
[client]
default-character-set = utf8
[mysqld]
default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci

3、更新MySQL的用户名密码

首先查看MySQL是否运行,确保MySQL是stop状态,可以使用/etc/init.d/mysql stop停止运行

1
2
root@kali:~# /etc/init.d/mysql status
[info] MySQL is stopped..

然后启动MySQL的server/daemon process

1
root@kali:~# mysqld_safe –skip-grant-tables &

使用root用户连接MySQL

1
2
3
4
5
6
7
8
9
10
root@kali:~# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.44–0+deb7u1 (Debian)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>

更改root用户的密码为admin

1
2
3
4
5
6
7
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set password=PASSWORD(‘admin’) where User=‘root’;
Query OK, 4 rows affected (0.01 sec)
Rows matched: 4 Changed: 4 Warnings: 0

执行更新命令

1
2
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

flush privileges 命令本质上的作用是将当前user和privilige表中的用户信息/权限设置从mysql库(MySQL数据库的内置库)中提取到内存里。MySQL用户数据和权限有修改后,希望在”不重启MySQL服务”的情况下直接生效,那么就需要执行这个命令。通常是在修改ROOT帐号的设置后,怕重启后无法再登录进来,那么直接flush之后就可以看权限设置是否生效。而不必冒太大风险。

退出

1
mysql> quit

4、验证用户密码是否更新成功

重启MySQL

1
2
3
4
5
6
7
root@kali:~# /etc/init.d/mysql restart
[ ok ] Stopping MySQL database server: mysqld.
[….] Starting MySQL database server: mysqld151015 11:41:36 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
[ .k
[info] Checking for tables which need an upgrade, are corrupt or were
not closed cleanly..
[1]+ 完成 mysqld_safe –skip-grant-tables

使用root用户连接MySQL

1
2
3
4
5
6
7
8
9
10
11
root@kali:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 5.5.44–0+deb7u1 (Debian)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>

metasploit Database not connect问题解决

1、postgresql是本身没有启动的。所以需要启动。

1
service postgresql start

2、通过命令进入配置

1
2
sudo -u postgres psql
ALTER USER postgres WITH PASSWORD ‘123.com’;

注意1:‘123.com’这个是密码。
注意2:分号!!!!一定要带上分号“;”。
注意3:\q:退出数据库

3、修改linux系统的postgres用户的密码(密码与数据库用户postgres的密码相同)

1
2
3
4
5
6
root@kali:~# sudo passwd -d postgres
passwd:密码过期信息已更改。
root@kali:~# sudo -u postgres passwd
输入新的 UNIX 密码:
重新输入新的 UNIX 密码:
passwd:已成功更新密码

4、修改PostgresSQL数据库配置实现远程访问

1
2
3
4
5
6
7
8
root@kali:~# vi /etc/postgresql/9.4/main/postgresql.conf
更改#listen_addresses = ‘localhost’为 listen_addresses = ‘*’
更改#password_encryption = on为password_encryption = on
root@kali:~# vi /etc/postgresql/9.4/main/pg_hba.conf
在文档末尾加上以下内容
# to allow your client visiting postgresql server
host all all 0.0.0.0 0.0.0.0 md5
root@kali:~# service postgresql restart

注意1:“#”号,一定要把“#”删除掉。
注意2:在vi编辑模式下点击键盘字母a是进入编辑模式,编辑完成后点击“esc”退出编辑模式然后在最下方输入“:wq”保存并退出。

5、管理PostgreSQL用户和数据库

1
root@kali:~# psql -U postgres -h 127.0.0.1

用户 postgres 的口令:
psql (9.4.6)
SSL连接 (协议: TLSv1.2, 加密:ECDHE-RSA-AES256-GCM-SHA384,二进制位: 256, 压缩比: 关闭)
输入 “help” 来获取帮助信息

1
2
3
4
5
6
7
postgres=# create user “msf123” with password ‘123456’ nocreatedb;
CREATE ROLE
postgres=# create database “msf1” with owner=”msf123”;
ERROR: role “”msf123”” does not exist
postgres=# create database “msf1″ with owner=”msf123”;
CREATE DATABASE
postgres=# \q

注意1:还是要注意分号!!!没有分号命令就无法执行。
注意2:注意复制的时候“”符号问题。
注意3:user后面是用户名,password后面是用户名对应的密码。
注意4:命令执行后有返回结果才是执行成功了。

6、msf配置连接

1
2
3
4
5
6
7
8
root@kali:~# msfconsole
msf > db_status
[*] postgresql selected, no connection
msf > db_connect msf123:123456@127.0.0.1/msf1
[*] Rebuilding the module cache in the background…
msf > db_status
[*] postgresql connected to msf1
msf >

在msf启动后连接数据库就好。
注意1:“msf123:123456”这个是步骤5中的
“create user “msf123” with password ‘123456’ nocreatedb;”所建立的。
“127.0.0.1”是指本机。
“msf1”这个是库名。
注意2:“[*] postgresql connected to msf1”这个是说明以链接成功数据库。

kali linux apt-get 证书校验错误

错误信息

1
2
3
4
5
6
7
8
9
root@teamserver:~# apt-get update
Get:1 http://mirror.neostrada.nl/kali kali-rolling InRelease [30.5 kB]
Err:1 http://mirror.neostrada.nl/kali kali-rolling InRelease
The following signatures were invalid: EXPKEYSIG ED444FF07D8D0BF6 Kali Linux Repository <devel@kali.org>
Fetched 30.5 kB in 1s (25.5 kB/s)
Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://mirror.neostrada.nl/kali kali-rolling InRelease: The following signatures were invalid: EXPKEYSIG ED444FF07D8D0BF6 Kali Linux Repository <devel@kali.org>
W: Failed to fetch http://http.kali.org/kali/dists/kali-rolling/InRelease The following signatures were invalid: EXPKEYSIG ED444FF07D8D0BF6 Kali Linux Repository <devel@kali.org>
W: Some index files failed to download. They have been ignored, or old ones used instead.

Kali 证书链过期 重新下载新的证书链

1
wget -q -O - archive.kali.org/archive-key.asc | apt-key add

####安装32位运行库

1
2
3
dpkg --add-architecture i386
apt-get update
apt-get install lib32z1 lib32ncurses5