博文

目前显示的是 三月, 2019的博文

ubuntu18.04 mysql5.7/mariadb10.1 set root password

1. Login (use sudo to login without password) sudo mysql -u root 2. Check SELECT User,Host FROM mysql.user; 3. Delete out root user DROP USER 'root'@'localhost'; 4. Create new root user CREATE USER 'root'@'%' IDENTIFIED BY 'your_password'; 5. Grant permissions GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; 6. FLUSH PRIVILEGES;

Shell Symbols

$# csh, sh Number of arguments to script $* csh, sh Arguments to script $@ sh Original arguments to script $- sh Flags  passed to shell ${array[@]} leads to each element of the array being treated as a separate shell-word ${array[*]} results in a single shell-word with all of the elements of the array separated by spaces (or whatever the first character of IFS is) Difference between $@ and $* $@ ./test_shell "w1 w2" w3 w4 $@ will be w1 w2 w3 w4 $* ./test_shell "w1 w2" w3 w4 $* will be w1 w2 w3 w4

OpenWRT opkg install error: Cannot satisfy dependencies

After flashing the local compiled image to my route, I got this error when using opkg install sometimes: * satisfy_dependencies_for: Cannot satisfy the following dependencies for iptables-mod-tproxy: * kernel (= 4.9.152-1-0b692028eb19a63deb9c9d19c9fee83c) * opkg_install_cmd: Cannot install package iptables-mod-tproxy. Here is how the OpenWRT official site says: You will get the message  “Cannot satisfy the following dependencies for…” if the kernel version installed on your device does not match the kernel version required by the package you want to install. This happens very easily when you are using a snapshot image. Try to install via opkg with option  --force-depends  (=Install/remove despite failed dependencies). Mind that this is likely to fail for kernel related packages (kmods). Make local copy of snapshot packages (not recommended, needs much space!) if you are using a snapshot image, and the snapshot packages are missing in current builds. Wait

About Netgear WNDR4300v1 5GHz missing problem

After flashing OpenWRT to Netgear WNDR4300v1, I surprisingly found that 5GHz wireless card was missing. And I tried to flash back to OEM version but ended up in dead loop rebooting. The 5GHz wifi of WNDR4300 is provided by AR9580 which is connected by the PCI interface. I used dmesg to inspect the log of openwrt and found that PCI found nothing when starting. Was the chip broken? I nearly gave up and tried to disconnect the router with its power and went to dinner. After the dinner, I powered up the router and -- it just worked! Here is the log from dmesg. [     0.391671] PCI host bridge to bus 0000:00 [     0.396044] pci_bus 0000:00: root bus resource [mem 0x10000000-0x13ffffff] [     0.403409] pci_bus 0000:00: root bus resource [io   0x0000] [     0.409340] pci_bus 0000:00: root bus resource [??? 0x00000000 flags 0x0] [     0.416575] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff] [     0.425036] pci 0000:00:00.0: [168c:0033] type 00 cl

Compile specific OpenWRT version and change the mtdlayout

1. Clone OpenWRT project from github git clone https://github.com/openwrt/openwrt.git 2. Find the release info from their github page. Click the 'X releases' tab can copy the commit number of the release you want. 3. Enter the folder of your cloned openwrt and reset header to that release. git reset --hard <commit number> 4. Install feeds. ./scripts/feeds update -a ./scripts/feeds install -a 5. Config. You must choose your target according to your router. make menuconfig e.g.: For router Netgear WNDR4300 * Target System => Atheros AR7xxx/AR9xxx * Subtarget  => Generic devices with nand flash * Target Profile => Netgear WNDR4300v1 * You may need LuCi Web admin interface. Please choose LuCi/Collections/luci 6. Download all packages before make make download 7. Make. (If you are in China, you may encounter some errors caused by GFW. Try to use a proxy to solve the problem.) make 8. The image will be in ./bin/targets/<your

Use Nmap to Scan Ports (cheat sheet)

1.Basic scan nmap 41.22.10.1 nmap yourdomain.com 2.Scan specific ports nmap -p 1-65535 41.22.10.1 nmap -p 1,443 41.22.10.1 3.Scan multipul ips nmap 1.1.1.1 1.1.1.2 nmap 1.1.1.1,2,3,4 (This will scan 1.1.1.1 1.1.1.2 1.1.1.3 1.1.1.4) nmap 1.1.1.1-4 nmap 1.1.1.* nmap 1.1.1.0/28 4.Scan popular ports nmap --top-ports 20 1.1.1.1 (Scan 20 ports of 1.1.1.1) 5.Scan target from a file nmap -iL list.txt 6.Scan an Service detection nmap -A -T4 1.1.1.1 (-A is for service detection. -T4 speeds up this operation) 7.Detect Service/Daemon nmap -sV 1.1.1.1 8.Scan using UDP/TCP nmap -sT 1.1.1.1 (For TCP) nmap -sU 1.1.1.1 (For UDP) 9.Vulnerability detection nmap -Pn --script vuln 1.1.1.1 10.Launch DOS Attack nmap 1.1.1.1 -max-parallelism 800 -Pn --script http-slowloris --script-args http-slowloris.runforever=true 11.Lauch brute force attacks nmap -sV --script http-wordpress-

Use IBM kubernetes

1. Install some related plugins. $ curl -sL https://ibm.biz/idt-installer | bash 2. Login to IBM Cloud Container Registry CLI $ ibmcloud cr login 3. Check the namespace in your registry. $ ibmcloud cr namespace-list 4. Build. $ ibmcloud cr build -t us.icr.io/<namespace>/hello-world:1 . 5. Run image. $ kubectl run hello-world-deployment --image=us.icr.io/<namespace>/hello-world:1 -- <your params> 6. Then you can login to your IBM Cloud control panel to check the status of your container. 7. Expose certain port. $ kubectl expose deployment/hello-world-deployment --type=NodePort --port=8080 --name=hello-world-service --target-port=8080 ------------------------------------------------------------ Other useful commands: 1. Get your current deployments. $ kubectl get deployments 2. Inspect the basic information of your deployment. $ kubectl describe deployments <your deployment's name> 3. Stop the deployment $ kubectl delete deployment