ubuntu18.04误用kali源后导致系统混乱,求恢复办法!!!

系统安装、升级讨论
回复
ubuntu_to_xu
帖子: 23
注册时间: 2008-12-10 20:59
送出感谢: 0
接收感谢: 0

ubuntu18.04误用kali源后导致系统混乱,求恢复办法!!!

#1

帖子 ubuntu_to_xu » 2018-08-24 17:40

因为想使用kali系统中一些工具,在网上找到katoolin这个工具软件可以用来添加kali工具包,印象中我好像只使用了katoolin运行后的
选项1 add kali repositories&update
进入下一级菜单后又选择了
1 add kali liunx repositories
后来执行了apt update,然后问题就来了 :Cool
先是发现我的ubuntu18.04桌面有些变化...,隐约有些不安,折腾了一会确定是有事情发生了 :Faint 。重启机器,居然发现grub界面都变成kali的了!
进入桌面,一番检查:
$ cat /etc/apt/sources.list
# deb cdrom:[Ubuntu 17.10 _Artful Aardvark_ - Release amd64 (20180105.1)]/ artful main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ bionic main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ artful main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ artful-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://cn.archive.ubuntu.com/ubuntu/ bionic universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ artful universe
deb http://cn.archive.ubuntu.com/ubuntu/ bionic-updates universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ artful-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://cn.archive.ubuntu.com/ubuntu/ bionic multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ artful multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ artful-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb-src http://cn.archive.ubuntu.com/ubuntu/ artful-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu artful partner
deb-src http://archive.canonical.com/ubuntu artful partner

deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb-src http://security.ubuntu.com/ubuntu artful-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
deb-src http://security.ubuntu.com/ubuntu artful-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
deb-src http://security.ubuntu.com/ubuntu artful-security multiverse
源恢复到正常,apt update,问题依旧...

lsb_release -a
No LSB modules are available.
Distributor ID: Kali
Description: Kali GNU/Linux Rolling
Release: kali-rolling
Codename: kali-rolling
我这ubuntu已经变成 Kali了 :Cry ,好多软件和系统功能不能正常使用
已经把katoolin这个工具软件(py文件)上传

有大侠帮忙可邮件xu.sz@outlook.com,谢谢。
附件
katoolin.py
可使用:python katoolin.py 运行
(50.1 KiB) 下载 7 次
ubuntu_to_xu
帖子: 23
注册时间: 2008-12-10 20:59
送出感谢: 0
接收感谢: 0

Re: ubuntu18.04误用kali源后导致系统混乱,求恢复办法!!!

#2

帖子 ubuntu_to_xu » 2018-08-24 18:18

查了下py脚本,我的选项应该执行了下面的操作。
if repo == "1":
cmd1 = os.system("apt-key adv --keyserver pgp.mit.edu --recv-keys ED444FF07D8D0BF6")
cmd2 = os.system("echo '# Kali linux repositories | Added by Katoolin\ndeb http://http.kali.org/kali kali-rolling main contrib non-free' >> /etc/apt/sources.list")
elif repo == "2":
cmd3 = os.system("apt-get update -m")
头像
astolia
论坛版主
帖子: 3295
注册时间: 2008-09-18 13:11
送出感谢: 1 次
接收感谢: 552 次

Re: ubuntu18.04误用kali源后导致系统混乱,求恢复办法!!!

#3

帖子 astolia » 2018-08-24 20:24

首先把软件包变动历史给复制一份

代码: 全选

cp /var/log/apt/history.log /tmp/
然后去编辑/tmp/history.log,看它的Start-Date,把你加kali源之前的都删掉。如果这之后有你手动安装删除的内容,也删掉
里面剩下的应该就只有两种操作Install:和Upgrade:。
对于Install的,就直接删掉列出的软件包,Upgrade的就降级到它列出的旧版本上,比如它有个 aaa (0.01, 0.02)这样的,你就apt install aaa=0.01
基本操作就是这样,只不过涉及到的包比较多,要手动操作比较累
弄了个shell脚本,看得懂就用,看不懂别乱用,小心出更大的错

代码: 全选

apt install $(grep 'Upgrade' /tmp/history.log | sed 's/Upgrade://;s/ (/=/g;s/, \S*)//g;s/,/ /g') $(grep 'Install' /tmp/history.log | sed 's/Install://;s/ (\S*, \S*)/-/g;s/ (\S*)/-/g;s/,/ /g')
poloshiao
论坛版主
帖子: 18274
注册时间: 2009-08-04 16:33
送出感谢: 21 次
接收感谢: 1948 次

Re: ubuntu18.04误用kali源后导致系统混乱,求恢复办法!!!

#4

帖子 poloshiao » 2018-08-24 20:34

$ cat /etc/apt/sources.list
# deb cdrom:[Ubuntu 17.10 _Artful Aardvark_ - Release amd64 (20180105.1)]/ artful main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ bionic main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ artful main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ artful-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://cn.archive.ubuntu.com/ubuntu/ bionic universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ artful universe
deb http://cn.archive.ubuntu.com/ubuntu/ bionic-updates universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ artful-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://cn.archive.ubuntu.com/ubuntu/ bionic multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ artful multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ artful-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb-src http://cn.archive.ubuntu.com/ubuntu/ artful-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu artful partner
deb-src http://archive.canonical.com/ubuntu artful partner

deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb-src http://security.ubuntu.com/ubuntu artful-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
deb-src http://security.ubuntu.com/ubuntu artful-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
deb-src http://security.ubuntu.com/ubuntu artful-security multiverse
源恢复到正常,apt update,问题依旧...
你混用了 18.04 跟 17.10 的源 ?
這個可能會引起系統不穩定問題
建議 全新安裝 比較快而穩定
ubuntu_to_xu
帖子: 23
注册时间: 2008-12-10 20:59
送出感谢: 0
接收感谢: 0

Re: ubuntu18.04误用kali源后导致系统混乱,求恢复办法!!!

#5

帖子 ubuntu_to_xu » 2018-08-25 20:40

谢谢,周一做好备份工作按你的办法试一下。
我是从17升级到18的。
ubuntu_to_xu
帖子: 23
注册时间: 2008-12-10 20:59
送出感谢: 0
接收感谢: 0

Re: ubuntu18.04误用kali源后导致系统混乱,求恢复办法!!!

#6

帖子 ubuntu_to_xu » 2018-08-27 9:55

astolia 写了:
2018-08-24 20:24
首先把软件包变动历史给复制一份

代码: 全选

cp /var/log/apt/history.log /tmp/
然后去编辑/tmp/history.log,看它的Start-Date,把你加kali源之前的都删掉。如果这之后有你手动安装删除的内容,也删掉
里面剩下的应该就只有两种操作Install:和Upgrade:。
对于Install的,就直接删掉列出的软件包,Upgrade的就降级到它列出的旧版本上,比如它有个 aaa (0.01, 0.02)这样的,你就apt install aaa=0.01
基本操作就是这样,只不过涉及到的包比较多,要手动操作比较累
弄了个shell脚本,看得懂就用,看不懂别乱用,小心出更大的错

代码: 全选

apt install $(grep 'Upgrade' /tmp/history.log | sed 's/Upgrade://;s/ (/=/g;s/, \S*)//g') $(grep 'Install' /tmp/history.log | sed 's/Install://;s/ (\S*, \S*)/-/g;s/ (\S*)/-/g;s/,/ /g')
附件是添加kali源后的history,我记得我是24日9点几分的时候执行的py脚本,然后又选择update。
接下来10点后的操作,应该是我在尝试修复 :Haha
你给的脚本我还没用,不知道是否适用,所以先贴出尽可能详细的信息。非常感谢你的帮助。
附件
附件.txt
apt history.log
(61.3 KiB) 下载 8 次
头像
astolia
论坛版主
帖子: 3295
注册时间: 2008-09-18 13:11
送出感谢: 1 次
接收感谢: 552 次

Re: ubuntu18.04误用kali源后导致系统混乱,求恢复办法!!!

#7

帖子 astolia » 2018-08-27 10:07

重点在09:35:50和09:51:45那两次,把这两次升级的降回去基本就行了
ubuntu_to_xu
帖子: 23
注册时间: 2008-12-10 20:59
送出感谢: 0
接收感谢: 0

Re: ubuntu18.04误用kali源后导致系统混乱,求恢复办法!!!

#8

帖子 ubuntu_to_xu » 2018-08-27 10:22

astolia 写了:
2018-08-27 10:07
重点在09:35:50和09:51:45那两次,把这两次升级的降回去基本就行了
我把history修改的就剩09:35:50和09:51:45那两次,然后执行脚本,报错:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
E: 未找到“speech-dispatcher-espeak-ng”的“0.8.8-1ubuntu1,”版本
E: 未找到“speech-dispatcher-audio-plugins”的“0.8.8-1ubuntu1,”版本
E: 未找到“hunspell-en-gb”的“1:6.0.3-3,”版本
E: 未找到“libpam0g”的“1.1.8-3.6ubuntu2,”版本
E: 未找到“debconf”的“1.5.66,”版本
E: 未找到“libgssapi3-heimdal”的“7.5.0+dfsg-1,”版本
E: 未找到“libgssapi3-heimdal:i386”的“7.5.0+dfsg-1,”版本
E: 未找到“libgoa-backend-1.0-1”的“3.28.0-0ubuntu2.1,”版本
E: 未找到“python3-pexpect”的“4.2.1-1,”版本
E: 未找到“libjson-glib-1.0-0”的“1.4.2-3,”版本
E: 未找到“hunspell-en-us”的“1:2017.08.24,”版本
E: 未找到“libgcc-7-dev”的“7.3.0-16ubuntu3,”版本
E: 未找到“manpages”的“4.15-1,”版本
E: 未找到“perl-base”的“5.26.1-6ubuntu0.2,”版本
E: 未找到“init”的“1.51,”版本
...
头像
astolia
论坛版主
帖子: 3295
注册时间: 2008-09-18 13:11
送出感谢: 1 次
接收感谢: 552 次

Re: ubuntu18.04误用kali源后导致系统混乱,求恢复办法!!!

#9

帖子 astolia » 2018-08-27 10:40

漏了点东西,稍微改下

代码: 全选

apt install $(grep 'Upgrade' /tmp/history.log | sed 's/Upgrade://;s/ (/=/g;s/, \S*)//g;s/,/ /g') $(grep 'Install' /tmp/history.log | sed 's/Install://;s/ (\S*, \S*)/-/g;s/ (\S*)/-/g;s/,/ /g')
ubuntu_to_xu
帖子: 23
注册时间: 2008-12-10 20:59
送出感谢: 0
接收感谢: 0

Re: ubuntu18.04误用kali源后导致系统混乱,求恢复办法!!!

#10

帖子 ubuntu_to_xu » 2018-08-27 13:49

astolia 写了:
2018-08-27 10:40
漏了点东西,稍微改下

代码: 全选

apt install $(grep 'Upgrade' /tmp/history.log | sed 's/Upgrade://;s/ (/=/g;s/, \S*)//g;s/,/ /g') $(grep 'Install' /tmp/history.log | sed 's/Install://;s/ (\S*, \S*)/-/g;s/ (\S*)/-/g;s/,/ /g')
按照你的方法,我的系统恢复了!谢谢。
中间出现apt install 找不到软件版本的问题,也是按你的方法,修改history文件中的版本号,再次运行脚本就可以安装了。
目前我的桌面环境、系统版本等一些不能使用的软件都已恢复正常,如果有其它问题我再帖出来。
回复

回到 “系统安装和升级”