Hack The Box 获取邀请码

时间:2022-11-04 08:36:26

TL DR;

  1. 使用curl请求下面的地址

curl -X POST https://www.hackthebox.eu/api/invite/generate



{"success":1,"data":{"code":"RlFLVEEtVUhZR0wtQ1RYUk4tSElYQUctSUhDTUo=","format":"encoded"},"0":200}

2. 在返回结果的code部分使用base64解密获取邀请码

echo 'RlFLVEEtVUhZR0wtQ1RYUk4tSElYQUctSUhDTUo=' | base64 -D



FQKTA-UHYGL-CTXRN-HIXAG-IHCMJ

```

详细步骤

  1. 查看邀请页面请求的内容,其中https://www.hackthebox.eu/js/inviteapi.min.js这个是所需要的,将里面的内容解密。解密过程很简单,网上又很多的在线JavaScript解密工具都可以完成。

    解密后的JavaScript

function verifyInviteCode(code) {

var formData = {

"code": code

};

$.ajax({

type: "POST",

dataType: "json",

data: formData,

url: '/api/invite/verify',

success: function(response) {

console.log(response)

},

error: function(response) {

console.log(response)

}

})

}

function makeInviteCode() {

$.ajax({

type: "POST",

dataType: "json",

url: '/api/invite/how/to/generate',

success: function(response) {

console.log(response)

},

error: function(response) {

console.log(response)

}

})

}

```

  1. 上面这个文件解密后就很清楚了,我们先执行第二个函数第二个,在控制台输入makeInviteCode()

    返回下面的内容

{0: 200, success: 1, data: {…}}

这里的data部分是被加密的,加密方式是随机的几种,网上搜索对应的解密工具即可。返回值中包含了加密的文本和加密方式,解密后得到下面的内容。

In order to generate the invite code, make a POST request to /api/invite/generate

```

  1. 照着上面的内容去做,你可以使用任何工具

    之前都是在控制台,这次也在控制台输入下面内容。这里的$就是jQuery不是Chrome里querySelector,因为这个页面已经载入了jQuery。

$.post('https://www.hackthebox.eu/api/invite/generate',function(data){console.log(data)})

```

返回结果

```

{0: 200, success: 1, data: {code: "UVpJVFItSlpLVU0tV1pXTVItUERTRVotS0RPVlg=", format: "encoded"}}

```

这里和上面一样,把date的code部分解密就可以看到邀请码了。