Skip to content
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
62 changes: 57 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
"compare-versions": "^3.4.0",
"core-js": "^2.5.4",
"highlight.js": "^9.15.6",
"ip-range-check": "^0.2.0",
"ipaddr.js": "^2.2.0",
"jquery": "^3.4.1",
"ng": "0.0.0",
"ngx-highlightjs": "^3.0.3",
Expand Down
42 changes: 30 additions & 12 deletions src/app/components/lan-table/lan-table.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {Component, OnInit, OnDestroy, ViewChild} from '@angular/core';
import ipaddr from 'ipaddr.js';
import isIpInRange from 'ip-range-check';
import {Component, OnInit, OnDestroy} from '@angular/core';
import { SortService, ColumnSortedEvent } from '../../services/sort.service';
import { ApiService } from '../../services/api.service';
import { Host } from '../../models/host';
Expand Down Expand Up @@ -59,8 +61,25 @@ export class LanTableComponent implements OnInit, OnDestroy {
this.sortSub.unsubscribe();
}

isSpoofed(host : any) : boolean {
return (host.ipv4 in this.spoofList);
isSpoofed(host: any): boolean {
if (host.mac == this.gateway.mac) {
return false;
}

const whitelistedTargets = this.spoofOpts.whitelist
.split(',')
.map((s) => s.trim())
.filter((s) => s.length);

if (isIpInRange(host.ipv4, whitelistedTargets)) {
return false;
}

if (host.ipv4 in this.spoofList) {
return true;
}

return isIpInRange(host.ipv4, Object.keys(this.spoofList));
}

private updateSpoofOpts() {
Expand Down Expand Up @@ -133,8 +152,6 @@ export class LanTableComponent implements OnInit, OnDestroy {
}

private update(session) {
const ipRe = /^(?=.*[^\.]$)((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.?){4}$/;

let spoofing = this.api.session.env.data['arp.spoof.targets']
// split by comma and trim spaces
.split(',')
Expand All @@ -153,13 +170,14 @@ export class LanTableComponent implements OnInit, OnDestroy {
this.spoofList = {};
// if there are elements that are not IP addresses, it means the user
// has set the variable manually, which overrides the UI spoof list.
for( let i = 0; i < spoofing.length; i++ ) {
if( ipRe.test(spoofing[i]) ) {
this.spoofList[spoofing[i]] = true;
} else {
this.spoofList = {};
break;
}
for (let i = 0; i < spoofing.length; i++) {
let spoofedTarget = spoofing[i];
if (ipaddr.isValid(spoofedTarget) || ipaddr.isValidCIDR(spoofedTarget)) {
this.spoofList[spoofedTarget] = true;
} else {
this.spoofList = {};
break;
}
}

this.iface = session.interface;
Expand Down