Files

54 lines
2.2 KiB
JavaScript

const https = require('https');
const AUTH_EMAIL = 'ziad.abd.elgwad2003@gmail.com';
const AUTH_PASS = '2062003Mz*';
function req(method, url, headers = {}, body = null) {
return new Promise(resolve => {
const u = new URL(url);
const data = body ? (typeof body === 'string' ? body : JSON.stringify(body)) : null;
const opts = {
hostname: u.hostname, port: 443, path: u.pathname + u.search, method,
headers: { ...headers }
};
if (data && !opts.headers['Content-Type']) opts.headers['Content-Type'] = 'application/json';
if (data) opts.headers['Content-Length'] = Buffer.byteLength(data);
const r = https.request(opts, res => {
let d = '';
res.on('data', c => d += c);
res.on('end', () => resolve({ status: res.statusCode, headers: res.headers, body: d }));
});
r.on('error', err => resolve({ error: err.message }));
if (data) r.write(data);
r.end();
});
}
async function main() {
const loginRes = await req('POST', 'https://auth.ghaymah.systems/signin/email-password', {}, {
email: AUTH_EMAIL, password: AUTH_PASS
});
const token = JSON.parse(loginRes.body).session.accessToken;
console.log('[+] Obtained token');
const tests = [
{ method: 'GET', url: 'https://gateway.ghaymah.systems/api' },
{ method: 'GET', url: 'https://gateway.ghaymah.systems/api/apps' },
{ method: 'GET', url: 'https://gateway.ghaymah.systems/api/projects' },
{ method: 'GET', url: 'https://integrations.ghaymah.systems/api' },
{ method: 'GET', url: 'https://integrations.ghaymah.systems/api/github' },
{ method: 'GET', url: 'https://integrations.ghaymah.systems/api/integrations' },
{ method: 'GET', url: 'https://logs.ghaymah.systems/logs?app_id=c4d0f564-90a8-4012-ace1-dff92d477134' },
{ method: 'POST', url: 'https://logs.ghaymah.systems/logs', body: { app_id: 'c4d0f564-90a8-4012-ace1-dff92d477134' } }
];
for (const t of tests) {
const res = await req(t.method, t.url, { Authorization: `Bearer ${token}` }, t.body);
console.log(`\n[${t.method}] ${t.url}`);
console.log(` Status: ${res.status}`);
console.log(` Body: ${res.body ? res.body.substring(0, 300) : '<empty>'}`);
}
}
main();