Implements open port results into UI

This commit is contained in:
Alicia Sykes 2023-07-01 23:17:21 +01:00
parent 5e7c3d167f
commit a8981b8ca7
3 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,36 @@
import styled from 'styled-components';
import colors from 'styles/colors';
import Card from 'components/Form/Card';
import Heading from 'components/Form/Heading';
import Row from 'components/Form/Row';
const Outer = styled(Card)`
small {
margin-top: 1rem;
opacity: 0.5;
}
`;
const OpenPortsCard = (portData: any): JSX.Element => {
return (
<Outer>
<Heading as="h3" align="left" color={colors.primary}>Open Ports</Heading>
{portData.openPorts.map((port: any) => (
<Row key={port} lbl="" val="">
<span>{port}</span>
</Row>
)
)}
<br />
<small>
Unable to establish connections to:<br />
{portData.failedPorts.join(', ')}
</small>
</Outer>
);
}
export default OpenPortsCard;

View File

@ -144,6 +144,7 @@ const jobNames = [
'redirects',
'txt-records',
'status',
'ports',
// 'server-info',
'whois',
] as const;

View File

@ -25,6 +25,7 @@ import DnsRecordsCard from 'components/Results/DnsRecords';
import RedirectsCard from 'components/Results/Redirects';
import TxtRecordCard from 'components/Results/TxtRecords';
import ServerStatusCard from 'components/Results/ServerStatus';
import OpenPortsCard from 'components/Results/OpenPorts';
import ProgressBar, { LoadingJob, LoadingState, initialJobs } from 'components/misc/ProgressBar';
import keys from 'utils/get-keys';
import { determineAddressType, AddressType } from 'utils/address-type-checker';
@ -198,6 +199,16 @@ const Results = (): JSX.Element => {
.then(res => parseShodanResults(res)),
});
// Check for open ports
const [portsResults] = useMotherHook({
jobId: 'ports',
updateLoadingJobs,
addressInfo: { address: ipAddress, addressType: 'ipV4', expectedAddressTypes: ['ipV4', 'ipV6'] },
fetchRequest: () => fetch(`/check-ports?url=${ipAddress}`)
.then(res => res.json()),
});
// Fetch and parse domain whois results
const [whoIsResults] = useMotherHook<Whois>({
jobId: 'whois',
@ -282,6 +293,7 @@ const Results = (): JSX.Element => {
{ title: 'Redirects', result: redirectResults, Component: RedirectsCard },
{ title: 'TXT Records', result: txtRecordResults, Component: TxtRecordCard },
{ title: 'Server Status', result: serverStatusResults, Component: ServerStatusCard },
{ title: 'Open Ports', result: portsResults, Component: OpenPortsCard },
];
return (