-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathshellgpt.py
87 lines (73 loc) · 2.13 KB
/
shellgpt.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"""
-----------------------------------------------------------------------
# shellgpt - chatgpt for shell
-----------------------------------------------------------------------
"""
__author__ = "z0nd3rl1ng"
__version__ = "1.0.0"
import random, os
try:
import openai
except ModuleNotFoundError:
print("[*] install missing module: openai")
os.system("pip3 install openai")
import openai
openai.api_key = "[PUT YOUR API KEY HERE]"
"""----------------------------------------------------------------"""
def shellGPT():
while True:
interact = input("[ShellGPT]╼> ")
if interact == "exit":
exit()
else:
response = openai.Completion.create(engine="text-davinci-002",
prompt=interact,
max_tokens=2048
)
print(response["choices"][0]["text"])
def banner():
padding = ' '
S = [[' ','┌','─','┐'],
[' ','└','─','┐'],
[' ','└','─','┘']]
H = [[' ','┬',' ','┬'],
[' ','├','─','┤'],
[' ','┴',' ','┴']]
E = [[' ','┌','─','┐'],
[' ','├','┤',' '],
[' ','└','─','┘']]
L = [[' ','┬',' ',' '],
[' ','│',' ',' '],
[' ','┴','─','┘']]
G = [[' ','┌','─','┐'],
[' ','│',' ','┬'],
[' ','└','─','┘']]
P = [[' ','┌','─','┐'],
[' ','│','─','┘'],
[' ','┴',' ',' ']]
T = [[' ','┌','─','┐'],
[' ',' ','│',' '],
[' ',' ','┴',' ']]
banner = [S,H,E,L,L,G,P,T]
final = []
print('\r')
init_color = random.randint(10,40)
txt_color = init_color
cl = 0
for charset in range(0, 3):
for pos in range(0, len(banner)):
for i in range(0, len(banner[pos][charset])):
clr = f'\033[38;5;{txt_color}m'
char = f'{clr}{banner[pos][charset][i]}'
final.append(char)
cl += 1
txt_color = txt_color + 36 if cl <= 3 else txt_color
cl = 0
txt_color = init_color
init_color += 31
if charset < 2: final.append('\n ')
print(f" {''.join(final)}")
print(f'{padding} by z0nd3rl1ng\n')
if __name__ == "__main__":
banner()
shellGPT()