yjiang's cake

mac启用无线网卡监听模式及扫描

使用自带的airport启用监听模式

默认airport无法在终端下使用,需要把airport软连接到/usr/bin/等环境

sudo ln -sf /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/

airport 参数

airport <interface> <verb> <options>
-s #扫描当前可用网络
-z #断开无线,需要root权限

使用airport进入监听模式

  1. 使用命令 ifconfig 确定当前无线网卡名称
  2. airport -s 扫描当前周边无线,并选定一个,复制其mac地址,记住channel号
  3. sudo airport sniff 进入监听模式


使用wash扫描网络(需root权限)

sudo wash -i <interface>
#更多命令参照`wash --help`


使用reaver解PIN(需root权限)

sudo reaver -i <interface> -b <mac> -vv -c <channel>

android 5.0 去除wifi及信号标志上的感叹号

原因

android 5.0增加了网络可用性监测,但是检测服务器是google自己的服务器,然后...gfw

手机及电脑所需条件

  • 手机root权限
  • 电脑已安装adb tools

方式1 自建服务器,nginx/apache url_rewrite

#此处以nginx为例,增加如下url_rewrite规则
location /generate_204 { return 204; }

方式2 空文件

直接在网站的根目录下建立一个generate_204空文件,因为wifi监测机制中返回的内容为空也会当成204

创建好监测服务器后,执行如下

adb shell su -c "settings put global captive_portal_server {domain}"

方式3 永久禁用检查

adb shell su -c "settings put global captive_portal_detection_enabled 0"

为SSH创建权限最小化用户

目的

临时给朋友使用自己的SSH代理,但是又不想分配任何VPS的权限

方法

#useradd时使用-s参数为new session指定login shell
useradd -s /bin/false <username>
passwd <username>

使用

此方法添加的用户无法进行ssh操作,作为代理时需要勾选`不分配终端`或使用
ssh -CfNg -D <port> <username>@<ip>

使用AUTOSSH保证连接稳定性

#-M autossh的echo机制使用的端口,可以是任意不被占用的端口

autossh -M <monitor_port> <ssh command>

如: autossh -M <autossh_port> -CfNg -D <port> <username>@<ip>

ssh参数说明

-C #数据压缩
-f #后台运行
-N #不执行脚本或命令
-g #允许远程主机连接转发端口
-D <port>转发到本地端口

SSH反向代理的应用--跳板

目的

机器B做跳板,从机器A访问机器B的2222端口时,重定向到机器C的22端口

登陆机器B执行

ssh -CfNg -L 3333:{机器C的IP}:22 user@{机器C IP}

参数说明 </h4>

-C  表示压缩数据传输
-f  表示后台用户验证,这个选项很有用,没有shell的不可登陆账号也能使用
-N  表示不执行脚本或命令
-g  表示允许远程主机连接转发端口(在本文示例中此参数并未生效,原因不明,所以才有了步骤2)

-L  表示本地转发  ssh -L <local port>:<remote host>:<remote port> <SSH hostname>

-R  表示远程转发  ssh -R <local port>:<remote host>:<remote port> <SSH hostname>

扩展应用

  • 对单线路国外VPS使用国内阿里云等多线VPS作为跳板进行加速
  • 换成非22端口亦可以,例如把机器C的80转发到机器B的8000
  • 在没有路由权限的情况下,内网映射端口到外网(//todo)

注意事项

  • 非管理员帐号无权绑定 1-1023 端口

参考引用

cubieboard(lubuntu)下释放nand

root@cubier:~# ls /dev/nan*
/dev/nand  /dev/nanda  /dev/nandb  /dev/nandc
root@cubier:~# df -lh
文件系统        容量  已用  可用 已用% 挂载点
/dev/root       1.8G  1.5G  266M   85% /
devtmpfs        382M  4.0K  382M    1% /dev
tmpfs            20M  4.0K   20M    1% /tmp
none             96M  252K   96M    1% /run
none            5.0M     0  5.0M    0% /run/lock
none            478M     0  478M    0% /run/shm
none            100M   12K  100M    1% /run/user
root@cubier:~# nand-part -f a20 /dev/nand
check partition table copy 0: mbr: version 0x00000200, magic softw411
OK
check partition table copy 1: mbr: version 0x00000200, magic softw411
BAD!
check partition table copy 2: mbr: version 0x00000200, magic softw411
BAD!
check partition table copy 3: mbr: version 0x00000200, magic softw411
BAD!
mbr: version 0x00000200, magic softw411
3 partitions
partition  1: class =         DISK, name =   bootloader, partition start =    32768, partition size =   131072 user_type=0
partition  2: class =         DISK, name =       rootfs, partition start =   163840, partition size =  6291456 user_type=0
partition  3: class =         DISK, name =        UDISK, partition start =  6455296, partition size =  1277952 user_type=0
root@cubier:~# nand-part -f a20 /dev/nand 32768 "bootloader 131072" "rootfs 7569408"
check partition table copy 0: mbr: version 0x00000200, magic softw411
OK
check partition table copy 1: mbr: version 0x00000200, magic softw411
BAD!
check partition table copy 2: mbr: version 0x00000200, magic softw411
BAD!
check partition table copy 3: mbr: version 0x00000200, magic softw411
BAD!
mbr: version 0x00000200, magic softw411
3 partitions
partition  1: class =         DISK, name =   bootloader, partition start =    32768, partition size =   131072 user_type=0
partition  2: class =         DISK, name =       rootfs, partition start =   163840, partition size =  6291456 user_type=0
partition  3: class =         DISK, name =        UDISK, partition start =  6455296, partition size =  1277952 user_type=0
check partition table copy 0: mbr: version 0x00000200, magic softw411
check partition table copy 1: mbr: version 0x00000200, magic softw411
check partition table copy 2: mbr: version 0x00000200, magic softw411
check partition table copy 3: mbr: version 0x00000200, magic softw411

ready to write new partition tables:
mbr: version 0x00000200, magic softw411
2 partitions
partition  1: class =         DISK, name =   bootloader, partition start =    32768, partition size =   131072 user_type=0
partition  2: class =         DISK, name =       rootfs, partition start =   163840, partition size =  7569408 user_type=0

write new partition tables? (Y/N)
y
Failed rereading partition table: Device or resource busy

verifying new partition tables:
check partition table copy 0: mbr: version 0x00000200, magic softw411
OK
check partition table copy 1: mbr: version 0x00000200, magic softw411
OK
check partition table copy 2: mbr: version 0x00000200, magic softw411
OK
check partition table copy 3: mbr: version 0x00000200, magic softw411
OK
mbr: version 0x00000200, magic softw411
2 partitions
partition  1: class =         DISK, name =   bootloader, partition start =    32768, partition size =   131072 user_type=0
partition  2: class =         DISK, name =       rootfs, partition start =   163840, partition size =  7569408 user_type=0
rereading partition table... returned -1
root@cubier:~#
root@cubier:~# resize2fs /dev/nandb
resize2fs 1.42.5 (29-Jul-2012)
Filesystem at /dev/nandb is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/nandb is now 786432 blocks long.

root@cubier:~# df -lh
文件系统        容量  已用  可用 已用% 挂载点
/dev/root       3.0G  1.5G  1.4G   51% /
devtmpfs        382M  4.0K  382M    1% /dev
tmpfs            20M  4.0K   20M    1% /tmp
none             96M  252K   96M    1% /run
none            5.0M     0  5.0M    0% /run/lock
none            478M     0  478M    0% /run/shm
none            100M   12K  100M    1% /run/user

Copyright © 2016 yjiang's cake

返回顶部