Files
captchalmpoc/agent.js

58 lines
1.3 KiB
JavaScript

import { CaptchaLMSolver } from 'captchalm/client';
import readline from 'readline';
const solver = new CaptchaLMSolver();
const API_URL = 'http://localhost:3000';
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
console.log(`
🤖 Agent Log Uplink Initialize...
Target: ${API_URL}
-----------------------
`);
const postLog = async (content) => {
try {
process.stdout.write('Solving cryptographic challenge... ');
const start = Date.now();
const response = await solver.completeProtectedRequest(
`${API_URL}/api/challenge`,
`${API_URL}/api/posts`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
content,
agentId: 'Terminal-Agent-01'
})
}
);
const time = Date.now() - start;
if (response.ok) {
console.log(`✅ Solved in ${time}ms! Log committed.`);
} else {
console.log('❌ Access Denied.');
console.log(await response.text());
}
} catch (err) {
console.log('❌ Error:', err.message);
}
};
const ask = () => {
rl.question('\nEnter log entry (or Ctrl+C to quit): ', async (content) => {
if (content.trim()) {
await postLog(content);
}
ask();
});
};
ask();