日常小工具

MT_IT發表於2024-03-13

一、sshd X11Forwarding

1、修改sshd服務 
vi /etc/sshd/sshd_config  #修改如下內容
X11Forwarding yes
X11UseLocalhost no 

2、安裝包
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm 

yum install xorg-x11-xauth xorg-x11-font*
yum install google-chrome-stable_current_x86_64.rpm #chrome包 


3、除錯chrome,訪問使用mobaxterm(自帶x11轉發工具)
錯誤1:提示缺少動態連結庫,可以https://pkgs.org/search/?q=libavahi-common.so.3 在這裡搜尋然後安裝,
error while loading shared libraries: libavahi-common.so.3: cannot open shared object file: No such file or directory
示例: libavahi-common.so.3 => yum install avahi-libs

錯誤2: [26446:26446:0308/150842.806755:ERROR:zygote_host_impl_linux.cc(100)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
vi /opt/google/chrome/google-chrome,修改最後一行為<<exec -a "$0" "$HERE/chrome" "$@" "--no-sandbox">>

錯誤3:開啟後字元顯示[]
修改字符集: LANG=en_US.UTF-8,要切花中文 LANG=zh_CN.UTF-8


錯誤3: ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcpix")
暫未解決

二、netcat常用

1、開啟ssh埠 
nc -l -p 2222 -e /bin/bash #在連線建立的時候執行一個程式,並把它的標準輸入輸出重定向到網路連線上來
另外一個主機:nc $ip 2222 #可以向登入主機一樣操作

2、傳輸檔案
nc -l -p 8080 > image.jpg
nc 192.168.1.2 8080 < image.jpg

3、埠探測
nc -vz -w3 127.0.0.1 2222 #探測埠,-w超時時間

三、socat工具

1、網路策略
socat - TCP-LISTEN:8080 #主機1
socat - TCP:10.71.105.119:8080 #主機2去訪問主機的ip和埠,相當於把兩個連結給繫結起來
如果客戶端結束,服務端也會結束;如果提示地址佔用,推出當前session,重新連結即可

socat - TCP-LISTEN:8080,fork,reuseaddr #服務端新增引數後,可以同時應答多個連結過來的客戶端

2、埠轉發 
socat TCP-LISTEN:8080,fork,reuseaddr TCP:127.0.0.1:9090
socat TCP-LISTEN:8080,fork,reuseaddr  EXEC:/usr/bin/bash    # 服務端提供 shell

socat TCP-LISTEN:8081,reuseaddr,fork,crlf EXEC:/usr/bin/bash,stderr,setsid,setpgid,pty,ctty #更高階的一些引數
socat - TCP:127.0.0.1:8081 #直接登入

3、檔案傳輸
socat -u TCP-LISTEN:8080 open:record.log,create    # 服務端接收檔案
socat -u open:record.log TCP:localhost:8080        # 客戶端傳送檔案

另外一個小工具,rinetd