Files
captchalmpoc/agent.js

60 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(`
🤖 AI Agent Initialize...
Target: ${API_URL}
-----------------------
`);
const postTweet = async (content) => {
try {
process.stdout.write('Solving captcha... ');
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,
username: 'Verified Bot',
handle: '@gpt_agent'
})
}
);
const time = Date.now() - start;
if (response.ok) {
console.log(`✅ Solved in ${time}ms! Post created.`);
} else {
console.log('❌ Failed.');
console.log(await response.text());
}
} catch (err) {
console.log('❌ Error:', err.message);
}
};
const ask = () => {
rl.question('\nEnter tweet content (or Ctrl+C to quit): ', async (content) => {
if (content.trim()) {
await postTweet(content);
}
ask();
});
};
ask();