Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Auto Download" feature, downloads every interaction to local disk #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/components/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { ReactComponent as ThemeDarkButtonIcon } from "assets/svg/theme_dark_but
import { ReactComponent as ThemeSynthButtonIcon } from "assets/svg/theme_synth_button.svg";
import NotificationsPopup from "components/notificationsPopup";
import ResetPopup from "components/resetPopup";
import ToggleBtn from "components/toggleBtn";
import { handleDataExport } from "lib";
import { getStoredData, writeStoredData } from "lib/localStorage";
import { ThemeName, showThemeName } from "theme";
import "./styles.scss";

Expand Down Expand Up @@ -69,6 +71,19 @@ const Header = ({
</button>
);

const data = getStoredData();
const [inputData, setInputData] = useState<any>({
responseExport: data.responseExport
});

const handleToggleBtn = (e: any) => {

const currentStoredData = getStoredData();

setInputData({ ...inputData, responseExport: e.target.checked});
writeStoredData({ ...currentStoredData, responseExport: e.target.checked});
};

return (
<div id="header" className="header">
<div>interactsh</div>
Expand All @@ -77,6 +92,16 @@ const Header = ({
<ThemeButton theme="synth" />
<ThemeButton theme="blue" />
</div>

<div>Auto Download</div>
<div>
<ToggleBtn
name="responseExport"
onChangeHandler={handleToggleBtn}
value={inputData.responseExport}
/>
</div>

<div className="links">
<button
type="button"
Expand Down
14 changes: 14 additions & 0 deletions src/components/header/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@
margin-right: 0.8rem;
border-right: 1px solid rgba(255, 255, 255, 0.25);
}
& > div:nth-of-type(2) {
letter-spacing: -0.02rem;
text-align: left;
padding-right: 1rem;
color: #ffffff;
margin-right: 0.8rem;
border-right: 1px solid rgba(255, 255, 255, 0.25);
}
& > div:nth-of-type(3) {
text-align: left;
color: #ffffff;
font-size: 1.4rem;
padding-right: 1rem;
}
& > button:nth-of-type(1) {
margin-left: 0;
border-radius: 0.6rem;
Expand Down
6 changes: 6 additions & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ const getData = (key: string) =>
O.chain(O.fromNullable)
);

export const handleResponseExport = (item : any) => {
const fileName = `${format(Date.now(), "yyyy-MM-dd_hh:mm")}_${item.protocol}_${item['remote-address']}_${item['full-id']}_${item.id}.txt`;
downloadData(item['raw-request'], fileName);
}

export const handleDataExport = () => {
const values = pipe(
R.mapWithIndex((key) => ({ key, data: getData(key) }))(localStorage),
Expand Down Expand Up @@ -200,6 +205,7 @@ export const register = (
host,
correlationIdLength: currentData.correlationIdLength,
correlationIdNonceLength: currentData.correlationIdNonceLength,
responseExport: false,
increment: 1,
token,
telegram: {
Expand Down
1 change: 1 addition & 0 deletions src/lib/localStorage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const defaultStoredData: StoredData = {
correlationId: "",
correlationIdLength: process.env.REACT_APP_CIDL ? +process.env.REACT_APP_CIDL : 20,
correlationIdNonceLength: process.env.REACT_APP_CIDN ? +process.env.REACT_APP_CIDN : 13,
responseExport: false,
secretKey: "",
data: [],
aesKey: "",
Expand Down
1 change: 1 addition & 0 deletions src/lib/types/storedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const StoredData_ = summon((F) =>
correlationId: F.string(),
correlationIdLength: F.number(),
correlationIdNonceLength: F.number(),
responseExport: F.boolean(),
theme: ThemeName(F),

publicKey: F.string(),
Expand Down
4 changes: 4 additions & 0 deletions src/pages/homePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
poll,
decryptAESKey,
processData,
handleResponseExport,
copyDataToClipboard,
clearIntervals,
register,
Expand Down Expand Up @@ -213,6 +214,9 @@ const HomePage = () => {

// eslint-disable-next-line array-callback-return
const formattedString = processedData.map((item: any) => {

storedData.responseExport && handleResponseExport(item)

const telegramMsg = `<i>[${item['full-id']}]</i> Received <i>${item.protocol.toUpperCase()}</i> interaction from <b><a href="https://ipinfo.io/${item['remote-address']}">${item['remote-address']}</a></b> at <i>${format(new Date(item.timestamp), "yyyy-mm-dd_hh:mm:ss")}</i>`
storedData.telegram.enabled && notifyTelegram(telegramMsg, storedData.telegram.botToken, storedData.telegram.chatId, 'HTML')
return {
Expand Down