Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
#2
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvar1984 committed Jul 3, 2020
1 parent 80e6f24 commit 7b43371
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 61 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
> LiteOTP is a Simpe OTP API Client,
- Simple to use
- Support PHP5
- Multi providers
- Asyncronous
- Reusable
- Colorfull

## Installation

requires [php](https://php.net ) to run.
requires [php7](https://php.net ) to run.

### Install the dependencies and software.

Expand Down Expand Up @@ -42,7 +45,6 @@ try {

- Add more API
- Support international phone number
- get status code

License
----
Expand Down
4 changes: 2 additions & 2 deletions box.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"main": "main.php",
"output": "build/lite",
"stub": true,
"algorithm" :"SHA512",
"compression" :"BZ2"
"algorithm": "SHA512",
"compression": "GZ"
}
Binary file modified build/lite
Binary file not shown.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"require": {
"ext-curl": "*",
"ext-bz2": "*",
"ext-zlib": "*",
"campo/random-user-agent": "^1.3",
"amphp/parallel": "^1.4"
},
Expand Down
104 changes: 50 additions & 54 deletions main.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Amp\Parallel\Worker;
use Amp\Promise;

$app = new Otp;
$app = new Otp();

if ($app->os != 'Linux') {
$R = '';
Expand Down Expand Up @@ -50,70 +50,66 @@
BANNER;

try {
if ($argc < 2) {
throw new \RuntimeException('Please input number phone');
}
if ($argc < 2) throw new \InvalidArgumentException('Read README.md');

if (is_numeric($argv[1])) {
$no = $argv[1];
while (1) {
printf('%sSend OTP to %s[%s]%s%s', $G, $Y, $no, $X, PHP_EOL);
$promises[] = Worker\enqueueCallable(
'\\Cvar1984\\LiteOtp\\Otp::tokopedia',
$no
);
$promises[] = Worker\enqueueCallable(
'\\Cvar1984\\LiteOtp\\Otp::jdid',
$no
);
$promises[] = Worker\enqueueCallable(
'\\Cvar1984\\LiteOtp\\Otp::phd',
$no
);
$promises[] = Worker\enqueueCallable(
'\\Cvar1984\\LiteOtp\\Otp::pedulisehat',
$no
);
$responses = Promise\wait(Promise\all($promises));

/* foreach($responses as $key => $value) */
/* { */
/* echo $value; */
/* } */
}
} elseif (is_file($argv[1])) {
$no = $argv[1];
$no = file_get_contents($no);
$no = trim($no, " \t\n\r\0\x0B"); //remove whitespace
$no = explode(PHP_EOL, $no);
$count = sizeof($no);
$providers = ['tokopedia', 'jdid', 'phd', 'pedulisehat'];

if (is_numeric($argv[1])) {
$number = $argv[1];
while (1) {
for ($x = 0; $x < $count; $x++) {
printf('%sSend OTP to %s[%s]%s%s', $G, $Y, $no[$x], $X, PHP_EOL);
$promises[] = Worker\enqueueCallable(
'\\Cvar1984\\LiteOtp\\Otp::tokopedia',
$no[$x]
foreach ($providers as $provider) {
printf(
'%sSend OTP to %s[%s]%s%s',
$G,
$Y,
$number,
$X,
PHP_EOL
);
$promises[] = Worker\enqueueCallable(
'\\Cvar1984\\LiteOtp\\Otp::jdid',
$no[$x]
printf('%sProvider %s[%s]%s%s', $G, $Y, $provider, $X, PHP_EOL);
$promises[$provider] = Worker\enqueueCallable(
'\Cvar1984\\LiteOtp\\Otp::' . $provider,
$number
);
$promises[] = Worker\enqueueCallable(
'\\Cvar1984\\LiteOtp\\Otp::phd',
$no[$x]
$responses = Promise\wait(Promise\all($promises));
/* foreach($responses as $key => $value) */
/* { */
/* echo $value; */
/* } */
}
}
}

$fileName = $argv[1];

if (!is_file($fileName)) throw new \Exception($fileName . ' Is not a file');
if (!is_readable($fileName)) throw new \Exception('Permission denied');

$content = file_get_contents($fileName);
$content = trim($content, " \t\n\r\0\x0B"); //remove whitespace
$numbers = explode(PHP_EOL, $content);

while (1) {
foreach ($providers as $provider) {
foreach ($numbers as $index => $number) {
printf(
'%sSend OTP to %s[%s]%s%s',
$G,
$Y,
$number,
$X,
PHP_EOL
);
$promises[] = Worker\enqueueCallable(
'\\Cvar1984\\LiteOtp\\Otp::pedulisehat',
$no[$x]
printf('%sProvider %s[%s]%s%s', $G, $Y, $provider, $X, PHP_EOL);
$promises[$index] = Worker\enqueueCallable(
'\Cvar1984\\LiteOtp\\Otp::' . $provider,
$number
);
$responses = Promise\wait(Promise\all($promises));
}
}
} else {
throw new \RuntimeException($argv[1] . ' Is not a file');
}
} catch (\Exception | \RuntimeException $e) {
} catch (\Exception | \InvalidArgumentException $e) {
fprintf(STDERR, "%s%s%s\n", $RR, $e->getMessage(), $X);
exit(1);
}
2 changes: 1 addition & 1 deletion src/Otp.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

final class Otp extends Request
{
public $version = '2.1.0';
public $version = '2.1.1';
public $os = PHP_OS;
public $author = 'Cvar1984';
public $team = 'BlackHole Security';
Expand Down

0 comments on commit 7b43371

Please sign in to comment.