-
Notifications
You must be signed in to change notification settings - Fork 0
/
sudo_pass_gui_cli.py
52 lines (40 loc) · 1.78 KB
/
sudo_pass_gui_cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import tkinter as tk
from tkinter import *
import os
from os import popen
#Note: The program that should be executed with sudo can be changed at "def pass_pw"
class App(tk.Tk):
def __init__(self):
super().__init__()
app_width = 300
app_height = 300
screen_width = self.winfo_screenwidth()
screen_height = self.winfo_screenheight()
x = (screen_width / 2) - (app_width / 2)
y = (screen_height / 2) - (app_height / 2)
self.geometry(f"{app_width}x{app_height}+{int(x)}+{int(y)}")
self.wait_visibility(self)
self.wm_attributes("-alpha", 0.90)
self["background"] = "#333333"
self.resizable(0, 0)
#self.overrideredirect(True)
global user
user = os.environ.get('LOGNAME')
print(f"Hi,{user} waz uuuuup?!")
self.labl = tk.Label(self, text=f"Hi, {user}!\n\nSudo Legitimation",background="#333333",foreground="white",font=("Helvetica", 16),)
self.labl.pack(pady=20,padx=20)
self.entry = tk.Entry(show='*')
self.entry.pack()
self.btn = tk.Button(self, text="Ok",command=self.pass_pw,highlightthickness=2,borderwidth=0,background="#333333",foreground="white",font=("Helvetica", 12, "bold"))
self.btn.pack(pady=20)
self.btn = tk.Button(self, text="Cancel",command=self.quit,highlightthickness=2,borderwidth=0,background="#333333",foreground="white",font=("Helvetica", 12, "bold"))
self.btn.pack(pady=20)
def pass_pw(self):
pw = self.entry.get()
pw = str(pw)
popen(f"xterm -e 'bash -c \"echo '{pw}' | sudo -S apt update && exit; exec bash\"'") # replace sudo apt update with "what evaa"
app.quit()
if __name__ == "__main__":
app = App()
app.title("")
app.mainloop()