Skip to content

Instantly share code, notes, and snippets.

View antimech's full-sized avatar

Artur Gauzer antimech

View GitHub Profile
@antimech
antimech / BotManController.php
Last active November 22, 2023 09:14
Здесь фрагменты кода в одном из старых проектов под NDA (к которому есть доступ из дома) опубликованные с разрешения их владельцев, здесь только начинаю применять сервис-классы. Проект сделан на Laravel + Botman.
<?php
namespace App\Http\Controllers;
use App\Conversations\AddAlertConversation;
use App\Conversations\RemoveAlertConversation;
use App\Services\TimeGapService;
use App\TelegramUser;
use BotMan\BotMan\BotMan;
use Illuminate\Database\Eloquent\ModelNotFoundException;
@antimech
antimech / coinbase-commerce-create-checkout.php
Last active November 22, 2023 08:40
Create subscriptions plans (checkout) through Coinbase Commerce
#!/usr/bin/env php8.1
<?php
// $ composer require antimech/coinbase:^0.11.0
require __DIR__ . '/vendor/autoload.php';
$coinbase = new Coinbase;
// Promotion
@antimech
antimech / calc.php
Last active November 22, 2023 08:39
Калькулятор с использованием библиотеки chriskonnertz/string-calc. $ php calc.php и введите ваше выражение, например: 1+2*4+(4*4)
#!/usr/bin/env php8.1
<?php
// $ composer require chriskonnertz/string-calc:^2.0.0
require __DIR__ . '/vendor/autoload.php';
$stringCalc = new ChrisKonnertz\StringCalc\StringCalc();
$term = trim(fgets(STDIN)); // reads one line from STDIN
@antimech
antimech / brute-force-loki-wallet.sh
Last active November 22, 2023 08:28
Loki Wallet BruteForce Password Recovery. Helps if you forgot the password. The command line tools required: https://github.com/loki-project/loki/releases/latest
#!/usr/bin/env bash
start=`date +%s` # save start time
tries=0 # tries counter
dictionary=/usr/share/dict/words # you can specify your own dictonary
for word in $(< $dictionary);
do echo "Trying: $word";
((tries++))
echo -e "wallet.keys\n$word" | ./loki-wallet-cli | egrep "^Opened wallet" && echo -e "\nThe passphrase is: $word\n" && break;
@antimech
antimech / botman.php
Last active November 22, 2023 08:24
BotMan 2.0 + Laravel: Telegram Bot user profile picture snippet. The user have to `/start` the bot first.
<?php
$userId = 16246463;
// Get a list of profile pictures for a user
$userProfilePictures = $this->bot->sendRequest('getUserProfilePhotos', [
'user_id' => $userId,
]);
info($userProfilePictures);
@antimech
antimech / search-mac-device-vendor-offline.sh
Last active November 22, 2023 08:22
Search for MAC device vendor quickly (offline). Requires nmap installed. Use: $ mac 3C0518. Put in /bin/ directory and add +x permission for ease of use.
#!/usr/bin/env bash
NMAP_DICTIONARY_PATH=$(locate mac-prefixes)
grep $1 $NMAP_DICTIONARY_PATH
@antimech
antimech / parseDayOfWeek.php
Last active November 14, 2023 06:55
Находит в строке даты при помощи регулярного выражения и добавляет к ним дни недели.
#!/usr/bin/env php8.1
<?php
$string = 'Давайте устроим встречу 20.05.2022 и потом ещё одну 12.06.2022';
const DAYS_OF_WEEK = [
0 => 'вс',
1 => 'пн',
2 => 'вт',
3 => 'ср',
@antimech
antimech / generateCaptchaString.php
Last active November 14, 2023 06:55
Этот скрипт генерирует капчу которую сложно спутать с кирилицей и цифрами
#!/usr/bin/env php8.1
<?php
const CAPTCHA_LENGTH = 6;
$captchaSymbolsWhitelist = [
'I', 'U', 'Y', 'D', 'F', 'G', 'J', 'L', 'N', 'Q', 'R', 'S', 'V', 'W', 'Z',
'2', '3', '4', '5', '6', '7', '8', '9',
];
$whitelistLength = sizeof($captchaSymbolsWhitelist);
@antimech
antimech / auth.js
Last active October 2, 2023 15:24
JQuery smart auth script with Google reCAPTCHA
$('#sign-up form').submit(function (event) {
var $this = $(this),
email = $this.find("input[name='email']").val(),
password = $this.find("input[name='password']").val(),
repeatPassword = $this.find("input[name='repeatpassword']").val(),
captcha = grecaptcha.getResponse(widgetId1);
if (password !== repeatPassword) {
document.querySelector('#sign-up form input[name="repeatpassword"]').setCustomValidity('Passwords mismatch');
event.preventDefault();
@antimech
antimech / web.php
Last active May 28, 2023 06:35
Laravel Route Regular Expression Constraints example
<?php
Route::get('/welcome', function () {
return view('welcome');
});
Route::get('/{link}', 'LinkController@show')
->where(['link' => '[a-zA-Z0-9_]+'])
->name('link.show');