Что делать если нужно поставить какую-то Python-библиотеку а root-прав нет? То есть в систему библиотеку никак и ничего не поставить.
Есть как минимум два способа это решить правильно!
🔸 Сделать виртуальное окружение и ставить там что угодно.
Это позволит создать полностью независимое исполняемое окружение для ваших приложений.
Все библиотеки будут храниться в домашней директории юзера а значит доступ на запись имеется.
Создать очень просто:
python3 -m venv ~/venvs/myenvname
Теперь активируем окружение
# Linux
source ~/venvs/myenvname/bin/activate
# Windows
%userprofile%\venvs\myenvname\Scripts\activate.bat
Можно ставить любые библиотеки и запускать приложение.
Это стандартный метод работы с любым проектом. Если еще не используете его, то пора начинать. Даже при наличии root доступа!
🔸 Бывает, что нет возможности запустить приложение из своего виртуального окружения. Например, его запускает какой-то сервис от вашего юзера и вставить активацию окружения вы не можете.
В этом случае можно установить библиотеки для Python не глобально в систему, а только для юзера.
Выполните этот код в консоли:
python3 -m site
Вы получите что-то такое:
sys.path = [
'/home/user',
'/usr/lib/python37.zip',
'/usr/lib/python3.7',
'/usr/lib/python3.7/lib-dynload',
'/home/user/.local/lib/python3.7/site-packages',
...
]
USER_BASE: '/home/user/.local'
USER_SITE: '/home/user/.local/lib/python3.7/site-packages'
ENABLE_USER_SITE: True
Нас интересует параметр USER_SITE. Это путь к пользовательским библиотекам, которые доступны по умолчанию, если они есть.
Именно сюда будут устанавливаться модули если добавить флаг --user при установке чего-либо через pip
pip install --user requests
Для этой команды не нужны root-права.
После неё можно запускать системный интерпретатор без виртуальных окружений и установленная библиотека будет доступна для текущего юзера.
Параметр USER_BASE показывает корневую директорию для хранения user-библиотек. Её можно изменить с помощью переменной окружения PYTHONUSERBASE
export PYTHONUSERBASE=~/pylibs
python3 -m site
...
USER_BASE: '/home/user/pylibs'
USER_SITE: '/home/user/pylibs/lib/python3.7/site-packages'
Получается некоторое подобие виртуального окружения для бедных 😁 которое можно менять через эту переменную (не делайте так!Лучше venv!)
🔸 Дописывание пути в PYTHONPATH
Этот способ не входит в список "двух правильных", но тоже рабочий. Здесь придётся сделать всё несколько сложней.
Сначала ставим библиотеку в любое место указывая путь установки
pip3 install -t ~/mylibs modulename
Библиотека установится без привязки к какому-либо интерпретатору. То есть по умолчанию не будет видна. Теперь в нужный момент добавляем этот путь в sys.path или в PYTHONPATH.
Не буду советовать так делать. Единственный раз когда этот способ мне пригодился и решил поставленную задачу, это при создании общей библиотеки для кластера компьютеров.
Модули лежат в сети и подгружаются для всех из одного и того же места. То есть обновлять файлы требуется только один раз а не на всех хосты отдельно.
Минусы такого подхода:
▫️Нужно всем хостам пробить нужный путь в .bashrc или ещё куда-то чтобы он сетапился на старте.
▫️Чем больше хостов тем больше нагрузка на сеть. Иногда такой способ не подходит именно по этой причине. Тогда Ansible вам в помощь.
▫️Не очень подходит если хосты с разными операционками. Некоторые библиотеки различаются для Linux и Windows (там, где есть бинарники) и приходится мудрить более сложные схемы.
#tricks#basic
🚀BeforeCoinMarketCap Team is pleased to announce the first AIRDROP of BCMC1 Token 🚀
🏆 Reward for #Airdrop: 2,000 BCMC1 ($20) ➕ 250 BCMC1 ($2,5) ref ➕ 200 BCMC1 ($2) send announce
🏆 Reward for #Bounty: Up to 35,000 BCMC1 (~$350)
🔛 Airdrop Google Form for BeforeCoinMarketCap
🌐OFFICIAL CHANNELS:
Telegram
Twitter
Facebook
Instagram
LinkedIn
YouTube
Website: beforecoinmarketcap.com
BeforeCoinMarketCap
💰 Reward for #Airdrop: 2,000 BCMC1 ($20) ➕ 250 BCMC1 ($2,5) ref ➕ 200 BCMC1 ($2) send announce
💰 Reward for #Bounty: Up to 35,000 BCMC1 (~$350)
🖥 Fill the form:
https://docs.google.com/forms/d/1MbhzJpK1ikAWitHHjnekfrKY3ZQ8_Y147nCqqEqtjq4/edit
☝🏻Join the telegram chat
☝🏻 Follow our twitter page and retweet the pinned post.
BeforeCoinMarketCap is a platform for tracking initial placement of tokens, and audit of valid tokens with small volume. Our platform rewards users of valuable information and tokens of own ecosystem tokens. Visit beforecoinmarketcap.com for more details
🚀BeforeCoinMarketCap Team is pleased to announce the first AIRDROP of BCMC1 Token 🚀
🏆 Reward for #Airdrop: 2,000 BCMC1 ($20) ➕ 250 BCMC1 ($2,5) ref ➕ 200 BCMC1 ($2) send announce
🏆 Reward for #Bounty: Up to 35,000 BCMC1 (~$350)
🔛 Airdrop Google Form for BeforeCoinMarketCap
🌐OFFICIAL CHANNELS:
Telegram
Twitter
Facebook
Instagram
LinkedIn
YouTube
Website: beforecoinmarketcap.com
SIX MILLION DOLLAR payout just went to the whitehat named pwning.eth for finding a critical vulnerability in Aurora, making it the second-largest #bounty on record 👏🏼
No user funds were lost, and #Aurora quickly patched the bug, leading to a positive outcome for everyone 🎉
Read our #Bugfix Review ⬇️
https://medium.com/immunefi/aurora-infinite-spend-bugfix-review-6m-payout-e635d24273d
To the beautiful and wonderful BeforeCoinMarketCap Community!
Sincerest wishes for health, happiness, and peace during this Holidays season and throughout the coming year! We thank you all for your unlimited contribution. We hope you stay with us, there are many interesting things this coming year!
Let the spirit of love gently fill our hearts and homes. In this loveliest of seasons may you find many reasons for happiness.
From all of us at BeforeCoinMarketCap. 💝
#BCMC1#BeforeCoinMarketCap#Crypto#BCMCToken#Airdrop#Bounty
💧BeforeCoinMarketCap BOUNTY💧
(For 100 participants only💯)
Make a video about our platform: Post it on your official YouTube channel (3-5 minutes) $50 - $100 in BCMC1 token. We take into account the length and quality of the content.
Example: Please watch this videos for instructions: https://youtu.be/8t1ucZFnyL8 & https://youtu.be/aYrpgGpI074
1 Best video will receive 15,000BCMC1 ($200) and will posted on our social channels.🏆
Mandatory:
✅Describe the People IEO. (Community voting)
✅Describe the People IEO. (Participant projects)
✅Explain the MLM system (Ongoing token sales)
❗️Notice: The channel must have Minimum of 1000 subscribers. Your email will be blacklisted if you submit an old video link or if you do not follow the instructions given.
#BCMC1#BeforeCoinMarketCap#BCMC#Crypto#BCMCToken#bounty#Bounty
💎 BeforeCoinMarketCap New BOUNTY 💎
For 100 participants only💯
Bounty Tasks✅
Make a video about our platform: Post it on your official YouTube channel (3-5 minutes) $50 - $100 in BCMC1 token. We take into account the length and quality of the content.
📍Mandatory:
1. Describe the search window.
2. Describe the Announcement window
3. Explain the MLM system (Ongoing token sales):
4. Describe the promotion website
Best video will receive 20,000BCMC1 ($300) and will posted on our social channels.
📍Bounty Google Form
Notice: The channel must have Minimum of 1000 subscribers. Your email will be blacklisted if you submit an old video link or if you do not follow the instructions given.
#BCMC1#BeforeCoinMarketCap#BCMC#Crypto#BCMCToken#Bounty
#python#bounty#bugbounty#bypass#cheatsheet#enumeration#hacking#hacktoberfest#methodology#payload#payloads#penetration_testing#pentest#privilege_escalation#redteam#security#vulnerability#web_application
Payloads All The Things is a comprehensive collection of useful payloads and bypass techniques for web application security testing and penetration testing. It offers detailed documentation for each vulnerability, including how to exploit it and ready-to-use payloads, plus files for tools like Burp Intruder. You can contribute your own payloads or improvements, making it a collaborative resource. It also links to related projects for internal network and hardware pentesting, and provides learning resources like books and videos. Using this resource helps you efficiently find and test security weaknesses in web applications, improving your pentesting effectiveness and knowledge.
https://github.com/swisskyrepo/PayloadsAllTheThings