[Add] csrf
This commit is contained in:
parent
5042a108d8
commit
f775282e91
2 changed files with 35 additions and 45 deletions
|
|
@ -1,41 +1,13 @@
|
|||
import type { SDK, DefineAPI } from "caido:plugin";
|
||||
import type { Request } from "caido:utils";
|
||||
<<<<<<< HEAD
|
||||
import { ImplicitGrantController } from "./controller/implictGrant";
|
||||
import { AuthZCodeGrantController } from "./controller/authZCodeGrant";
|
||||
import { PKCECheck } from "./controller/PKCECheck";
|
||||
|
||||
export type API = DefineAPI<{}>;
|
||||
|
||||
const implicitGrantController = new ImplicitGrantController();
|
||||
const authZCodeGrantController = new AuthZCodeGrantController();
|
||||
const pkceCheck = new PKCECheck();
|
||||
|
||||
// function matchSSORequest(req: Request): boolean {
|
||||
// const raw = req.getRaw().toString();
|
||||
|
||||
// // 조건 3: Raw request에 SAMLRequest 또는 SAMLResponse 포함
|
||||
// if (raw.includes("SAMLRequest=") || raw.includes("SAMLResponse=")) {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// function matchAccessTokenResponse(resp: Response): boolean {
|
||||
// const raw = resp.getRaw().toString();
|
||||
|
||||
// const match = /"access_token"\s*:\s*"([^"]+)"/.exec(raw);
|
||||
// return !!match;
|
||||
// }
|
||||
=======
|
||||
import type { Request, Response } from "caido:utils";
|
||||
// import { ImplicitGrantController } from "./controller/implictGrant";
|
||||
// import { AuthZCodeGrantController } from "./controller/authZCodeGrant";
|
||||
import { CsrfCheck } from "./controller/csrfCheck";
|
||||
import { PKCECheck } from "./controller/PKCECheck";
|
||||
|
||||
export type API = DefineAPI<{}>;
|
||||
const csrfCheck = new CsrfCheck();
|
||||
>>>>>>> 8de17eb (csrf(state) 관련 취약점 탐지 기능 추가)
|
||||
const pkceCheck = new PKCECheck();
|
||||
|
||||
export function init(sdk: SDK<API>) {
|
||||
// sdk.events.onInterceptRequest(async (sdk, req: Request) => {
|
||||
|
|
@ -51,21 +23,23 @@ export function init(sdk: SDK<API>) {
|
|||
// }
|
||||
// });
|
||||
|
||||
sdk.events.onInterceptResponse(async (sdk, req: Request, resp) => {
|
||||
const funcList = [csrfCheck.checker(sdk, req, resp)];
|
||||
sdk.events.onInterceptResponse(
|
||||
async (sdk: SDK<DefineAPI<{}>, {}>, req: Request, resp: Response) => {
|
||||
const funcList: Promise<string | 0>[] = [
|
||||
csrfCheck.checker(sdk, req, resp),
|
||||
];
|
||||
|
||||
let result = await Promise.all(funcList);
|
||||
let result = await Promise.all(funcList);
|
||||
if (result) {
|
||||
await sdk.findings.create({
|
||||
title: "Possible SSO Response Detected",
|
||||
description: `SSO-related parameters detected in response:\n\n${req.getMethod()} ${req.getUrl()} : ${result}`,
|
||||
request: req,
|
||||
reporter: "",
|
||||
});
|
||||
}
|
||||
|
||||
if (result) {
|
||||
await pkceCheck.test(sdk, req);
|
||||
|
||||
await sdk.findings.create({
|
||||
title: "Possible SSO Response Detected",
|
||||
description: `SSO-related parameters detected in response:\n\n${req.getMethod()} ${req.getUrl()} : ${result}`,
|
||||
request: req,
|
||||
reporter: "",
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue