Skip to content

Commit 4637f0c

Browse files
authored
Upload
1 parent 030d567 commit 4637f0c

File tree

3 files changed

+408
-1
lines changed

3 files changed

+408
-1
lines changed

KeyAuth.pl

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
package KeyAuth;
2+
3+
require HTTP::Request;
4+
5+
use JSON::MaybeXS qw(encode_json);
6+
use JSON;
7+
use LWP::UserAgent;
8+
use Time::Piece;
9+
use Win32;
10+
11+
$Initialized = false;
12+
my $sessionid = "Null Session";
13+
14+
my $name = "";
15+
my $ownerid = "";
16+
my $version = "1.0";
17+
18+
$AppInfo{'numUsers'} = "";
19+
$AppInfo{'numOnlineUsers'} = "";
20+
$AppInfo{'numKeys'} = "";
21+
$AppInfo{'version'} = $version;
22+
$AppInfo{'customerPanelLink'} = "";
23+
24+
$user_data{'username'} = "";
25+
$user_data{'ip'} = "";
26+
$user_data{'hwid'} = "";
27+
$user_data{'createdate'} = "";
28+
$user_data{'lastlogin'} = "";
29+
30+
%user_data_Subscriptions = ( );
31+
32+
sub Api {
33+
$appname = $_[0];
34+
$appownerid = $_[1];
35+
$appsecret = $_[2];
36+
$appversion = $_[3];
37+
38+
print($appname, $appownerid, $appsecret, $appversion);
39+
40+
if (!$appname || !$appownerid || !$appsecret || !$appversion) {
41+
print("\n Error: Application is not set up correctly.");
42+
exit(0);
43+
};
44+
45+
$name = $appname;
46+
$ownerid = $appownerid;
47+
$version = $appversion;
48+
}
49+
50+
sub Init {
51+
my $url = "https://keyauth.win/api/1.1/?type=init&name=${name}&ownerid=${ownerid}&ver=${version}";
52+
$response = Req($url);
53+
54+
if ($response->decoded_content =~ "KeyAuth_Invalid") {
55+
print("Error: Application not found");
56+
exit(0);
57+
}
58+
59+
my $json = decode_json($response->content);
60+
61+
if ($json->{'success'}) {
62+
63+
$Initialized = true;
64+
$sessionid = $json->{'sessionid'};
65+
Load_AppInfo(encode_json($json->{'appinfo'}));
66+
} elsif ($json->{'message'} == "invalidver") {
67+
print("Error: Invalid version");
68+
exit(0);
69+
} else {
70+
print("Error: " . $json->{'message'});
71+
exit(0);
72+
}
73+
}
74+
75+
sub Upgrade {
76+
$Username = $_[0];
77+
$Key = $_[1];
78+
79+
my $url = "https://keyauth.win/api/1.1/?type=upgrade&name=${name}&ownerid=${ownerid}&sessionid=${sessionid}&key=${Key}&username=${Username}";
80+
$response = Req($url);
81+
my $json = decode_json($response->content);
82+
83+
if ($json->{'success'}) {
84+
print("Successfully upgraded!");
85+
exit(0);
86+
} else {
87+
print("Error: " . $json->{'message'});
88+
exit(0);
89+
}
90+
}
91+
92+
sub Login {
93+
$Username = $_[0];
94+
$Password = $_[1];
95+
96+
$hwid = GetHwid();
97+
98+
my $url = "https://keyauth.win/api/1.1/?type=login&name=${name}&ownerid=${ownerid}&sessionid=${sessionid}&username=${Username}&pass=${Password}&hwid=${hwid}";
99+
$response = Req($url);
100+
my $json = decode_json($response->content);
101+
102+
if ($json->{'success'}) {
103+
Load_UserData(encode_json($json->{'info'}));
104+
} else {
105+
print("\nError: " . $json->{'message'});
106+
exit(0);
107+
}
108+
}
109+
110+
sub Register {
111+
$Username = $_[0];
112+
$Password = $_[1];
113+
$Key = $_[2];
114+
115+
$hwid = GetHwid();
116+
117+
my $url = "https://keyauth.win/api/1.1/?type=register&name=${name}&ownerid=${ownerid}&sessionid=${sessionid}&username=${Username}&pass=${Password}&key=${Key}&hwid=${hwid}";
118+
$response = Req($url);
119+
my $json = decode_json($response->content);
120+
121+
if ($json->{'success'}) {
122+
Load_UserData(encode_json($json->{'info'}));
123+
} else {
124+
print("\nError: " . $json->{'message'});
125+
exit(0);
126+
}
127+
}
128+
129+
sub License {
130+
$key = $_[0];
131+
132+
$hwid = GetHwid();
133+
134+
my $url = "https://keyauth.win/api/1.1/?type=license&name=${name}&ownerid=${ownerid}&sessionid=${sessionid}&key=${key}&hwid=${hwid}";
135+
$response = Req($url);
136+
my $json = decode_json($response->content);
137+
138+
if ($json->{'success'}) {
139+
Load_UserData(encode_json($json->{'info'}));
140+
} else {
141+
print("\nError: " . $json->{'message'});
142+
exit(0);
143+
}
144+
}
145+
146+
sub Var {
147+
$varid = $_[0];
148+
149+
my $url = "https://keyauth.win/api/1.1/?type=var&name=${name}&ownerid=${ownerid}&sessionid=${sessionid}&varid=${varid}";
150+
$response = Req($url);
151+
my $json = decode_json($response->content);
152+
153+
if ($json->{'success'}) {
154+
return $json->{'message'};
155+
} else {
156+
return "";
157+
}
158+
}
159+
160+
sub Setvar {
161+
$varid = $_[0];
162+
$data = $_[1];
163+
164+
my $url = "https://keyauth.win/api/1.1/?type=setvar&name=${name}&ownerid=${ownerid}&sessionid=${sessionid}&var=${varid}&data=${data}";
165+
$response = Req($url);
166+
my $json = decode_json($response->content);
167+
168+
if ($json->{'success'}) {
169+
return true;
170+
} else {
171+
return false;
172+
}
173+
}
174+
175+
sub Getvar {
176+
$varid = $_[0];
177+
178+
my $url = "https://keyauth.win/api/1.1/?type=getvar&name=${name}&ownerid=${ownerid}&sessionid=${sessionid}&var=${varid}";
179+
$response = Req($url);
180+
my $json = decode_json($response->content);
181+
182+
if ($json->{'success'}) {
183+
return $json->{'message'};
184+
} else {
185+
return "";
186+
}
187+
}
188+
189+
sub Check {
190+
$hwid = GetHwid();
191+
192+
my $url = "https://keyauth.win/api/1.1/?type=check&name=${name}&ownerid=${ownerid}&sessionid=${sessionid}&hwid=${hwid}";
193+
$response = Req($url);
194+
my $json = decode_json($response->content);
195+
196+
if ($json->{'success'}) {
197+
return true;
198+
} else {
199+
return false;
200+
}
201+
}
202+
203+
sub CheckBlacklist {
204+
$hwid = GetHwid();
205+
206+
my $url = "https://keyauth.win/api/1.1/?type=check&name=${name}&ownerid=${ownerid}&sessionid=${sessionid}&hwid=${hwid}";
207+
$response = Req($url);
208+
my $json = decode_json($response->content);
209+
210+
if ($json->{'success'}) {
211+
return true;
212+
} else {
213+
return false;
214+
}
215+
}
216+
217+
sub Webhook {
218+
$webid = $_[0];
219+
$params = $_[1];
220+
221+
my $url = "https://keyauth.win/api/1.1/?type=webhook&name=${name}&ownerid=${ownerid}&sessionid=${sessionid}&webid=${webid}&params=${params}";
222+
$response = Req($url);
223+
my $json = decode_json($response->content);
224+
225+
if ($json->{'success'}) {
226+
return $json->{'message'};
227+
} else {
228+
return "";
229+
}
230+
}
231+
232+
sub Log {
233+
$message = $_[0];
234+
$PcUser = Win32::LoginName || "UNKNOWN";
235+
$hwid = GetHwid();
236+
237+
my $url = "https://keyauth.win/api/1.1/?type=log&name=${name}&ownerid=${ownerid}&sessionid=${sessionid}&hwid=${hwid}&pcuser=${PcUser}&message=${message}";
238+
$response = Req($url);
239+
}
240+
241+
sub Load_UserData {
242+
$EncodedJson = $_[0];
243+
my $json = decode_json($EncodedJson);
244+
245+
$user_data{'username'} = $json->{'username'};
246+
$user_data{'ip'} = $json->{'ip'};
247+
$user_data{'hwid'} = $json->{'hwid'};
248+
$user_data{'createdate'} = $json->{'createdate'};
249+
$user_data{'lastlogin'} = $json->{'lastlogin'};
250+
251+
%user_data_Subscriptions = encode_json($json->{'subscriptions'});
252+
}
253+
254+
sub Load_AppInfo {
255+
$EncodedJson = $_[0];
256+
my $json = decode_json($EncodedJson);
257+
258+
$AppInfo{'numUsers'} = $json->{'numUsers'};
259+
$AppInfo{'numOnlineUsers'} = $json->{'numOnlineUsers'};
260+
$AppInfo{'numKeys'} = $json->{'numKeys'};
261+
$AppInfo{'version'} = $json->{'version'};
262+
$AppInfo{'customerPanelLink'} = $json->{'customerPanelLink'};
263+
}
264+
265+
sub Req {
266+
$url = $_[0];
267+
my $header = ['Content-Type' => 'application/x-www-form-urlencoded'];
268+
269+
my $r = HTTP::Request->new('POST', $url, $header);
270+
$ua = LWP::UserAgent->new;
271+
$response = $ua->request($r);
272+
return $response;
273+
}
274+
275+
sub UnixToDate {
276+
$unix = $_[0];
277+
$time = localtime($unix)->strftime('%F %T');
278+
return $time;
279+
}
280+
281+
sub GetHwid {
282+
$hwid = "PERL_EXAMPLE";
283+
return $hwid;
284+
}
285+
286+
sub ClearConsole {
287+
system("cls");
288+
}
289+
290+
return 1;

Main.pl

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package KeyAuth;
2+
require "./KeyAuth.pl";
3+
4+
KeyAuth::Api(
5+
"Application Name",
6+
"Application Owner ID",
7+
"Application Secret",
8+
"1.0"
9+
);
10+
11+
KeyAuth::ClearConsole();
12+
print "\n\n Initializing...\n";
13+
KeyAuth::Init();
14+
15+
print("
16+
App data:
17+
Number of users: " . $AppInfo{'numUsers'} . "
18+
Number of online users: " . $AppInfo{'numOnlineUsers'} . "
19+
Number of keys: " . $AppInfo{'numKeys'} . "
20+
Application Version: " . $AppInfo{'version'} . "
21+
Customer panel link: " . $AppInfo{'customerPanelLink'} . "
22+
");
23+
24+
print "\n [1] Login\n [2] Register\n [3] Upgrade\n [4] License key only\n\n Choose option: ";
25+
$choice = <STDIN>;
26+
chomp $choice;
27+
28+
if ($choice == "1") {
29+
print "\n Enter your username: ";
30+
$username = <STDIN>;
31+
chomp $username;
32+
print "\n Enter your password: ";
33+
$password = <STDIN>;
34+
chomp $password;
35+
36+
KeyAuth::Login($username, $password);
37+
38+
} elsif ($choice == "2") {
39+
print "\n Enter your username: ";
40+
$username = <STDIN>;
41+
chomp $username;
42+
print "\n Enter your password: ";
43+
$password = <STDIN>;
44+
chomp $password;
45+
print "\n Enter your license: ";
46+
$license = <STDIN>;
47+
chomp $license;
48+
49+
KeyAuth::Register($username, $password, $license);
50+
51+
} elsif ($choice == "3") {
52+
print "\n Enter your username: ";
53+
$username = <STDIN>;
54+
chomp $username;
55+
print "\n Enter your license: ";
56+
$license = <STDIN>;
57+
chomp $license;
58+
59+
KeyAuth::Upgrade($username, $license);
60+
61+
} elsif ($choice == "4") {
62+
print "\n Enter your license: ";
63+
$license = <STDIN>;
64+
chomp $license;
65+
66+
KeyAuth::License($license);
67+
68+
} else {
69+
print("\nNot Valid Option");
70+
exit(0);
71+
}
72+
73+
print("
74+
User Data:
75+
76+
Username: " . $user_data{'username'} . "
77+
IP address: " . $user_data{'ip'} . "
78+
Hardware-Id: " . $user_data{'hwid'} . "
79+
Created at: " . UnixToDate($user_data{'createdate'}) . "
80+
Last login: " . UnixToDate($user_data{'lastlogin'}) . "
81+
82+
");
83+
84+
$SubsDecoded = decode_json(%user_data_Subscriptions);
85+
my $Subs = $SubsDecoded;
86+
my $SubsLength = scalar @$Subs;
87+
88+
print(" Your subscription(s):\n");
89+
90+
for ( my $i = 0; $i < $SubsLength; $i++ ) {
91+
print(" Subscription Name: $SubsDecoded->[$i]{'subscription'} - Expires: " . UnixToDate($SubsDecoded->[$i]{'expiry'}) . " - Time left in seconds: $SubsDecoded->[$i]{'timeleft'}\n");
92+
};
93+
94+
print("
95+
\n Exiting in 10 secs...
96+
");
97+
sleep(10);
98+
exit(0);

0 commit comments

Comments
 (0)