Linux

Kali Linux add PPA repository add-apt-repository

뭉기 2014. 11. 26. 09:40

Kali Linux에서 우분투의 패키지를 마음대로 설치해보도록 하자.


출처 : http://www.blackmoreops.com/2014/02/21/kali-linux-add-ppa-repository-add-apt-repository/


A Personal Package Archive (PPA) is a special software repository for uploading source packages to be built and published as an APT repository by Launchpad or a similar application. While the term is used exclusively within Ubuntu, Launchpad host Canonical envisions adoption beyond the Ubuntu community.


Debian allows users to add and use PPA repositories by an application named add-apt-repository however, Kali Linux didn’t include this in their default package list. With Kali, because this is a special purpose application and certain modifications were made to make it work for what it does best (Penetration Test), there’s a chance that by adding untested and unsupported PPA repositories and application you might end up breaking your installation.


However, PPA is a powerful tool to have and a lot of the specific applications that are not available in repositories are available via PPA repositories. Users should take extra care before adding unknown and random repositories as it might very well break other things. I mean, how do you know the PPA owner didn’t add some harmful code in their system? Generally, you don’t. Then again, how do you know that Linux Kernel doesn’t have something that’s spying on your activity? But I guess that doesn’t matter, your ISP would be happy enough to hand over your online activity to NSA anyway … I could go on and on, but let’s not waste more time and move to actual post “Kali Linux add PPA repository add-apt-repository” .. so here goes ..


Step 1: Install required applications

First we install Python Software properties package.

apt-get install python-software-properties

Kali Linux add PPA repository add-apt-repository - install python-software-properties - 1 - blackMORE Ops

Next we install apt-file

apt-get install apt-file

Kali Linux add PPA repository add-apt-repository - install apt-file - 2 - blackMORE Ops

Update apt-file.

apt-file update

Kali Linux add PPA repository add-apt-repository - update apt-file - 3 - blackMORE Ops

This takes a while, so in case your apt-file update is SLOW, you might want to try and fix that as well. (Note that I got repo.kali.org in my /etc/apt/sources.list file instead of http.kali.org.)

Once apt-file update is complete, you should be able to search for it.

apt-file search add-apt-repository

Kali Linux add PPA repository add-apt-repository - search apt-file - 4 - blackMORE Ops

Your output should look similar to this:

python-software-properties: /usr/bin/add-apt-repository
python-software-properties: /usr/share/man/man1/add-apt-repository.1.gz

 

Step 2: Use our own code for add-apt-repository

The default add-apt-repository application located in (/usr/bin/add-apt-repository) works for Debian. So if you’re using Kali, chances are it won’t work. There’s a nice fix for that which I will add at the bottom of this post, (try them on VirtualBox if you feel like). But I found we can just mimic Ubuntu Oneiric to make add-apt-repository work.

cd /usr/sbin
vi add-apt-repository

Kali Linux add PPA repository add-apt-repository - adding add-apt-repository code - 5 - blackMORE Ops

Add the following code and save the file.

#!/bin/bash
if [ $# -eq 1 ]
NM=`uname -a && date`
NAME=`echo $NM | md5sum | cut -f1 -d" "`
then
  ppa_name=`echo "$1" | cut -d":" -f2 -s`
  if [ -z "$ppa_name" ]
  then
    echo "PPA name not found"
    echo "Utility to add PPA repositories in your debian machine"
    echo "$0 ppa:user/ppa-name"
  else
    echo "$ppa_name"
    echo "deb http://ppa.launchpad.net/$ppa_name/ubuntu oneiric main" >> /etc/apt/sources.list
    apt-get update >> /dev/null 2> /tmp/${NAME}_apt_add_key.txt
    key=`cat /tmp/${NAME}_apt_add_key.txt | cut -d":" -f6 | cut -d" " -f3`
    apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key
    rm -rf /tmp/${NAME}_apt_add_key.txt
  fi
else
  echo "Utility to add PPA repositories in your debian machine"
  echo "$0 ppa:user/ppa-name"
fi

Note: In this line echo "deb http://ppa.launchpad.net/$ppa_name/ubuntu oneiric main" >> /etc/apt/sources.list I’ve usedOneiric. You can try to use LucidRaring or Saucy as per your choice.


Now chmod and chown the file.

Kali Linux add PPA repository add-apt-repository - chown and chmod add-apt-repository - 6 - blackMORE Ops

 

chmod o+x /usr/sbin/add-apt-repository 
chown root:root /usr/sbin/add-apt-repository

 

Step 3: Adding a PPA repository via add-apt-repository in Kali Linux

Now that we added the correct code, we can use add-apt-repository to add a PPA repository. I tried the following to add themes and custom icons in Kali Linux.

Kali Linux add PPA repository add-apt-repository - adding PPA Repository using add-apt-repository - 7 - blackMORE Ops

 

/usr/sbin/add-apt-repository ppa:noobslab/themes
/usr/sbin/add-apt-repository ppa:alecive/antigone

Once you’ve added a PPA repository via add-apt-repository in Kali Linux, you need to update your package list.

apt-get update

You’ll see that your package list is now including PPA repository.

 

Step 4: Testing

Now that we have added add-apt-repository to add PPA repository in Kali Linux, we can try to add some themes and custom icons. To keep things clean, I’ve moved this part in a different describing adding custom themes and icons in Kali Linux.

 

Step 5: Advanced Way

(Continued from Step 2: Paragraph 1)

In Step 2, paragraph 1, I pointed that we need to use our own code to use add-apt-repository. Following is a way to bypass that and use /usr/bin/add-apt-repositoryby modifying your Distribution ID. I again advise that you  try this part in Virtual Box so that you can roll back your changes.

Step 5.a Install Python Software Properties:

Install Python Software properties package.

apt-get install python-software-properties -y

 

Step 5.b Change Distribution ID, Release, Codename and Description

Change your Distribution ID to Ubuntu, Release to 12.04, Codename to Precise and Description to Ubuntu 12.04 LTS.

echo -e "DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=12.04\nDISTRIB _CODENAME=precise\nDISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"" >> /etc/lsb-release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION=”Ubuntu 12.04 LTS”

 

UPDATE: 27/02/2014 – Added code for Ubuntu Oneiric 11.10

 

echo -e "DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=11.10\nDISTRIB _CODENAME=oneiric\nDISTRIB_DESCRIPTION="Ubuntu 11.10"" >> /etc/lsb-release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.10
DISTRIB_CODENAME=oneiric
DISTRIB_DESCRIPTION=”Ubuntu 11.10″

 

That mean’s now you can either use Precise or Oneiric codes as you feel like.

Kali Linux add PPA repository add-apt-repository - adding PPA Repository by modifying lsb_release details - 8 - blackMORE Ops

 

Now you should be able to add PPA just like normal.

 

Step 5.c Add PPA Repositories

Add PPA repositories using usual /usr/bin/add-apt-repository

add-apt-repository ppa:upubuntu-com/chat
apt-get update

 

Step 5.d Install something (i.e.Skype?)

Now we can install Skype..

apt-get install skype

 

Step 5.e Rollback changes

No change is much good without a rollback strategy.

To rollback your changes to Distribution ID, Release, Codename and Description, do the following,

echo -e "DISTRIB_ID=Debian\nDISTRIB_RELEASE=Kali Linux 1.0.6\nDISTRIB _CODENAME=n/a\nDISTRIB_DESCRIPTION="Debian GNU/Linux Kali Linux 1.0.6"" >> /etc/lsb-release

And to confirm, do another lsb_release -a

lsb_release -a

Output:

No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux Kali Linux 1.0.6
Release:    Kali Linux 1.0.6
Codename:   n/a

 

HUH .. GOTCHA …..

Just kidding… You don’t actually have to do it (well you could, but what’s the point to making things complicated). You could just delete/etc/lsb_release file that was created in Step 5.e.

rm /etc/lsb_release

We again do antther lsb_release -a to confirm.. See screenshot below:

Kali Linux add PPA repository add-apt-repository - adding PPA Repository by rollback lsb_release details - 9 - blackMORE Ops

Both ways works, but I prefer the second way where you delete /etc/lsb_release file. This file didn’t exist until we ran Step Step 5.e. So by deleting this file it doesn’t break or damage anything. So yes, just delete that file after you’ve installed whichever PPA you want.

 

Conclusion

As I’ve pointed in my first paragraph that by adding PPA repositories, you might break your system, so I will add a disclaimer here…

Disclaimer: This guide shows how to add PPA Repositories using add-apt-repository in Kali Linux that is usually not recommended. Readers should know how to repair their system and try these in Virtual Environment to avoid accidental breaks. We take no responsibility. Like Linux itself, you use these information’s as it is.

Thanks for reading.

If this worked for you, please share this article and like us on Facebook/Twitter.