Skip to content

Instantly share code, notes, and snippets.

View petrusnog's full-sized avatar
🏠
Coding from home

Petrus Nogueira petrusnog

🏠
Coding from home
  • Fortaleza - CE
View GitHub Profile
@petrusnog
petrusnog / getremotelogs.py
Last active August 5, 2022 17:00
A Python automation for getting access logs massively from a remote server.
#!/usr/bin/env python3
import os
import sys
import getopt
print("""
╔═╗╔═╗╔╦╗ ╦═╗╔═╗╔╦╗╔═╗╔╦╗╔═╗ ╦ ╔═╗╔═╗╔═╗
β•‘ ╦║╣ β•‘ ╠╦╝║╣ β•‘β•‘β•‘β•‘ β•‘ β•‘ β•‘β•£ β•‘ β•‘ β•‘β•‘ β•¦β•šβ•β•—
β•šβ•β•β•šβ•β• β•© β•©β•šβ•β•šβ•β•β•© β•©β•šβ•β• β•© β•šβ•β• β•©β•β•β•šβ•β•β•šβ•β•β•šβ•β•
""")
@petrusnog
petrusnog / curl_request_logs.php
Created March 24, 2023 01:09
Gets PHP cURL requisition logs
<?php
$curlHandle = curl_init();
$curl_setopt_array = [
CURLOPT_URL => 'https://google.com.br',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
@petrusnog
petrusnog / formatBrazilianPhone.php
Created April 27, 2023 03:28
Retrieves the phone structure from a given phone number.
<?php
/**
* @param string $phone_number
* @return string
*/
function formatBrazilianPhone($phone_number)
{
$phone_number = preg_replace( '/[^0-9]/', '', $phone_number );
$phone_object = [
@petrusnog
petrusnog / azure-ad-login-curl.php
Last active December 20, 2023 18:11
Two ways to login with AAD, one using cURL, another using GuzzleHttp. For the guzzle method, there's a composer.json file indexed.
<?php
$tenantId = 'common';
$authenticationUrl = "https://login.microsoft.com/{$tenantId}/oauth2/v2.0/authorize";
$clientId = "{seu-client-id}";
$clientSecret = '{seu-client-secret}';
$redirectUri = '{seu-redirect-uri}';
$scope = "openid profile offline_access User.Read"; // Escopo de permissΓ΅es necessΓ‘rias
$authenticationUrl .= "?client_id=$clientId&redirect_uri=$redirectUri&response_type=code&scope=$scope";
if (isset($_GET['code'])) {