Created
December 1, 2021 10:34
-
-
Save milisarge/e85bdb5ff6c8027f061a4e8672f5a5b1 to your computer and use it in GitHub Desktop.
Ayguci sudo ile erişim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| import pam | |
| sifre="1234567" | |
| kullanici="myuser" | |
| p=pam.pam() | |
| durum=p.authenticate(kullanici,sifre) | |
| cmd="sudo ayguci cli".split() | |
| sys_info='system/info^{"method":"get"}'.split() | |
| if durum: | |
| sifre_yaz= subprocess.Popen(["echo",sifre],stdout=subprocess.PIPE) | |
| yetkili_islem=subprocess.Popen(cmd+sys_info, | |
| stdin=sifre_yaz.stdout, | |
| stdout=subprocess.PIPE) | |
| islem_sonuc=yetkili_islem.stdout | |
| print("Çıktı:") | |
| print(islem_sonuc.read().decode()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment