([/tool fetch url="https://wtfismyip.com/text" output=user as-value]->"data")
วันอาทิตย์ที่ 7 ธันวาคม พ.ศ. 2568
วันพุธที่ 20 สิงหาคม พ.ศ. 2568
Resize Ubuntu VM disk
1st step: increase/resize disque from GUI console
2nd step : Extend physical drive partition
check free space : $sudo fdisk -l
$growpart /dev/sda 3 (Extend physical drive partition )
$pvdisplay ( See phisical drive )
$sudo pvresize /dev/sda3 (Instruct LVM that disk size has changed)
$ pvdisplay ( check physical drive if has changed )
[U]3rd step: Extend Logical volume [/U]
$ lvdisplay (# View starting LV)
$ sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv ( # Resize LV)
$ lvdisplay (# View changed LV)
4th step : Resize Filesystem
$ resize2fs /dev/ubuntu-vg/ubuntu-lv
$ fdisk -l (# Confirm results)
credit: https://forum.proxmox.com/threads/resize-ubuntu-vm-disk.117810/
วันพุธที่ 7 กันยายน พ.ศ. 2565
วิธีการ Reset กล้องวงจรปิด UNV (Uniview) แบบ linux shell
กล้อง UNV บางรุ่น เช่นกล้องแบบ Dome จะไม่มีปุ่ม Reset ทำให้ Reset แบบปกติไม่ได้ บทความนี้จะสอนวิธี Reset แบบใช้ Linux Command ครับ
![]() |
| กล้อง Dome ยี่ห้อ UNV |
![]() |
| รุ่น IPC322CR3-VSPF40-A |
![]() |
| การเชื่อมต่อ Console |
วันอาทิตย์ที่ 5 กันยายน พ.ศ. 2564
Modify Rootfs ของกล้อง Dahua (Imou) DH-IPC-C12P
เราสามารถแก้ไข rootfs ของกล้อง ip รุ่นนี้ได้โดยการ unpack -> แก้ไข -> repack -> สร้างไฟล์ .img คำสั่งที่ใช้มีดังนี้
1. unpack squashfs
sun89@TOT-Log-Server:~/Dahua IPC$ unsquashfs -d c12_rootfs_ori c12_rootfs.bin
2. เราจะได้ directory c12_rootfs_ori หลังจากแก้ไขเสร็จให้ repack squashfs
sun89@TOT-Log-Server:~/Dahua IPC$ mksquashfs c12_rootfs_ori c12_rootfs_mod1.bin -comp xz -Xdict-size 131072 -Xbcj arm -b 131072
3. สร้างไฟล์ c12_rootfs_mod1.bin romfs-x.squashfs.img เพื่อใช้ในการ upgrade ผ่าน micro sd-card
sun89@TOT-Log-Server:~/Dahua IPC$ mkimage -A arm -O linux -T standalone -C gzip -a 0x270000 -e 0x840000 -n romfs-by-sun -d c12_rootfs_mod1.bin romfs-x.squashfs.img
4. Upgrade ผ่านทาง micro sd-card
- copy ไฟล์ romfs-x.squashfs.img ใส่ใน sd-card
- ถอดปลั้กกล้องวงจรปิด
- เสียบ sd-card
- กดปุ่ม reset/wps ค้างไว้พร้อมกับเสียบไฟเข้ากล้อง อย่าเพิ่มปล่อยมือ!
- รอไฟสถานะกล้องกระพริบเป็นสีเขียวสลับแดงแล้วถึงจะปล่อยมือ
- เสร็จ.
โปรแกรม set baudrate ให้ TTYS0 สำหรับ embeded-devices ที่ไม่มี stty, screen
![]() |
#include <stdio.h>
#include <fcntl.h>
//#include <asm/termbits.h>
#include <termios.h>
int main() {
struct termios ttycfg;
int fd;
printf("Simple terminal TTYS0 baudrate change to 115200\n");
fd = open ("/dev/ttyS0", O_RDWR | O_NOCTTY);
if (fd < 0) {
printf("Error opening TTY /dev/ttyS0 \n");
return -1;
}
if (tcgetattr (fd, &ttycfg) < 0) {
printf("Error from tcgetattr\n");
return -1;
}
cfsetspeed (&ttycfg, B115200);
if (tcsetattr(fd, TCSANOW, &ttycfg) != 0) {
printf("Error from tcsetattr\n");
return -1;
}
printf("Success set baud\n");
return 0;
}
ผม cross-compile จากคอม x86 ไปเป็นโปรแกรมของ arm โดยใช้คำสั่ง
/home/sun89/cross/OpenWrt-Toolchain-kirkwood-for-arm_xscale-gcc-4.8-linaro_uClibc-0.9.33.2_eabi/toolchain-arm_xscale_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/bin/arm-openwrt-linux-uclibcgnueabi-g++ setbaud.c -o setbaud -O0 -Wall
วันอาทิตย์ที่ 22 สิงหาคม พ.ศ. 2564
unpack squashfs, modify, and repack
- Unpack cmd
unsquashfs -d c12_rootfs c12_rootfs.bin
Parallel unsquashfs: Using 4 processors
274 inodes (410 blocks) to write
[==============================================================================================================================================|] 410/410 100%
created 157 files
created 51 directories
created 117 symlinks
created 0 devices
created 0 fifos
- Get squashfs information
unsquashfs -s c12_rootfs.bin
Found a valid SQUASHFS 4:0 superblock on c12_rootfs.bin.Creation or last append time Wed Jul 25 08:41:03 2018Filesystem size 5699.83 Kbytes (5.57 Mbytes)Compression xzDictionary size 131072Filters selected: armBlock size 131072Filesystem is exportable via NFSInodes are compressedData is compressedFragments are compressedAlways-use-fragments option is not specifiedXattrs are compressedDuplicates are removedNumber of fragments 27Number of inodes 325Number of ids 1
-Repack again
mksquashfs c12_rootfs c12_rootfs_mod.bin -comp xz -Xdict-size 131072 -Xbcj arm -b 131072
Parallel mksquashfs: Using 4 processors
Creating 4.0 filesystem on c12_rootfs_mod.bin, block size 131072.
[==============================================================================================================================================-] 294/294 100%
Exportable Squashfs 4.0 filesystem, xz compressed, data block size 131072
compressed data, compressed metadata, compressed fragments, compressed xattrs
duplicates are removed
Filesystem size 5703.36 Kbytes (5.57 Mbytes)
25.62% of uncompressed filesystem size (22258.76 Kbytes)
Inode table size 2568 bytes (2.51 Kbytes)
22.61% of uncompressed inode table size (11359 bytes)
Directory table size 2842 bytes (2.78 Kbytes)
52.02% of uncompressed directory table size (5463 bytes)
Number of duplicate files found 26
Number of inodes 326
Number of files 158
Number of fragments 27
Number of symbolic links 117
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 51
Number of ids (unique uids + gids) 1
Number of uids 1
sun89 (1000)
Number of gids 1
sun89 (1000)
- Compare original and modify version
unsquashfs -s c12_rootfs.bin
Found a valid SQUASHFS 4:0 superblock on c12_rootfs.bin.
Creation or last append time Wed Jul 25 08:41:03 2018
Filesystem size 5699.83 Kbytes (5.57 Mbytes)
Compression xz
Dictionary size 131072
Filters selected: arm
Block size 131072
Filesystem is exportable via NFS
Inodes are compressed
Data is compressed
Fragments are compressed
Always-use-fragments option is not specified
Xattrs are compressed
Duplicates are removed
Number of fragments 27
Number of inodes 325
Number of ids 1
unsquashfs -s c12_rootfs_mod.bin
Found a valid SQUASHFS 4:0 superblock on c12_rootfs_mod.bin.
Creation or last append time Sun Aug 22 14:45:41 2021
Filesystem size 5703.36 Kbytes (5.57 Mbytes)
Compression xz
Dictionary size 131072
Filters selected: arm
Block size 131072
Filesystem is exportable via NFS
Inodes are compressed
Data is compressed
Fragments are compressed
Always-use-fragments option is not specified
Xattrs are compressed
Duplicates are removed
Number of fragments 27
Number of inodes 326
Number of ids 1
วันศุกร์ที่ 20 สิงหาคม พ.ศ. 2564
Deploy Flask Application to server
Link นี้อธิบายดีมาก
วันศุกร์ที่ 6 สิงหาคม พ.ศ. 2564
Use QEMU to run binary file from IP-Camera firmware
QEMU With Dynamic Linker
user@server:~/cross$ qemu-arm hello.out
/lib/ld-linux-armhf.so.3: No such file or directory
Response: Error
Fast fix: Add Static Linker when Compile
user@server:~/cross$ arm-linux-gnueabihf-gcc -static -o hello.out hello.c
user@server:~/cross$ qemu-arm hello.out
Hello, World!
Response: OK
Run Busybox file from ip-camera firmware
user@server:~/Dahua IPC/6_romfs/bin$ qemu-arm busybox
/lib/ld-uClibc.so.0: No such file or directory
Response: Fail Need lib
Fix by "ln" command
user@server:~/Dahua IPC/6_romfs/bin$ sudo ln -s /home/sun89/Dahua\ IPC/6_romfs/lib/ld-uClibc.so.0 /lib/ld-uClibc.so.0
user@server:~/Dahua IPC/6_romfs/bin$ qemu-arm busybox
busybox: can't load library 'libcrypt.so.0'
user@server:~/Dahua IPC/6_romfs/bin$ sudo ln -s /home/sun89/Dahua\ IPC/6_romfs/lib/libcrypt.so.0 /lib/
user@server:~/Dahua IPC/6_romfs/bin$ qemu-arm busybox
busybox: can't load library 'libm.so.0'
user@server:~/Dahua IPC/6_romfs/bin$ sudo ln -s /home/sun89/Dahua\ IPC/6_romfs/lib/libm.so.0 /lib/
user@server:~/Dahua IPC/6_romfs/bin$ qemu-arm busybox
busybox: can't load library 'libc.so.0'
user@server:~/Dahua IPC/6_romfs/bin$ sudo ln -s /home/sun89/Dahua\ IPC/6_romfs/lib/libc.so.0 /lib/
user@server:~/Dahua IPC/6_romfs/bin$ qemu-arm busybox
BusyBox v1.18.4 (2016-11-14 11:07:11 CST) multi-call binary.
Copyright (C) 1998-2009 Erik Andersen, Rob Landley, Denys Vlasenko
and others. Licensed under GPLv2.
See source distribution for full notice.
Usage: busybox [function] [arguments]...
or: busybox --list[-full]
or: function [arguments]...
BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as.
Currently defined functions:
[, [[, arp, arping, ash, awk, bash, cat, chgrp, chmod, chown, chroot, cp, cut, date, df, dhcprelay, dmesg, du, dumpleases, echo, egrep, eject, env,
fdisk, fgrep, find, flash_eraseall, free, fsync, getty, grep, halt, head, ifconfig, ifenslave, inetd, init, insmod, ip, ipaddr, iplink, iproute,
iprule, iptunnel, kill, killall, killall5, less, linuxrc, ln, login, ls, lsmod, lspci, lsusb, lzcat, lzma, mdev, mkdir, mknod, modinfo, more, mount,
mv, nanddump, nandwrite, netstat, nice, ping, ping6, pkill, poweroff, printenv, ps, pwd, reboot, rm, rmdir, rmmod, route, sed, seq, sh, sleep, stat,
sync, tail, tcpsvd, telnet, telnetd, test, tftp, tftpd, top, touch, ubiattach, ubidetach, ubimkvol, ubirmvol, ubirsvol, ubiupdatevol, udhcpd, udpsvd,
umount, uname, unlzma, unzip, vi, who, whoami
user@server:~/Dahua IPC/6_romfs/bin$ qemu-arm busybox ping 8.8.8.8.
ping: bad address '8.8.8.8.'
user@server:~/Dahua IPC/6_romfs/bin$ qemu-arm busybox ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
ping: permission denied (are you root?)
user@server:~/Dahua IPC/6_romfs/bin$ sudo qemu-arm busybox ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=113 time=30.814 ms
64 bytes from 8.8.8.8: seq=1 ttl=113 time=29.257 ms
64 bytes from 8.8.8.8: seq=2 ttl=113 time=30.371 ms
64 bytes from 8.8.8.8: seq=3 ttl=113 time=29.158 ms
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 29.158/29.900/30.814 ms
user@server:~/Dahua IPC/6_romfs/bin$
It's Work!
วันเสาร์ที่ 2 กุมภาพันธ์ พ.ศ. 2562
TP-Link Archer C5 v4 -> default_config.xml file decrypt
Decrypt Command: openssl enc -d -des-ecb -nopad -K 478da50ff9e3d2cb -in default_config.xml > default_config_decrypted.xml -iv 0
Encrypt Command: openssl enc -des-ecb -nopad -K 478da50ff9e3d2cb -in default_config_decrypted.xml > default_config.xml -iv 0
วันศุกร์ที่ 10 พฤศจิกายน พ.ศ. 2560
Tenda W311R Firmware Recovery By CFE (Unbrick)
1. Set PC IP address to 192.168.1.9/24.
2. Use tftpd for serve firmware file (w311r.trx).
3. Tear down W311R and solder TP1(SoC RX), TP2(SoC TX) and connect to PC.
4. Open serial port 115200 8n1 no-flow.
5. Press keyboard CTRL + C until it promp CFE>
6. Type "flash -noheader 192.168.1.9:w311r.trx flash0.trx"
7. Finish.
วันอังคารที่ 18 พฤศจิกายน พ.ศ. 2557
ADMboot Command ใน Planet VC-200
บันทึกช่วยจำ
- ต้องกด Space bar 3 ครั้งเพื่อเข้า Loader Menu
- กด 1 เพื่อดู Boot Parameter
- กด 2 เพื่อตั้ง MAC Address
- กด 3 เพื่อ Reboot เข้าระบบปกติ
- กด B เพื่อ Upgrade Bootloader ผ่านโปรโตคอล XMODEM
- กด X =??? -> เกี่ยวกับการ Upgrade
- กด T เพื่อ Upgrade Firmware ผ่าน TFTP Client
- ก่อนใช้ TFTP ได้ต้องตั้ง MAC ก่อนเช่น 00-11-22-33-44-55
- ตั้ง MAC แล้วกด T เพื่อเข้าเมนู TFTP Client
- กด S เพื่อตั้งค่า IP Server, IP Client, File name
- กด D ระบบจะ Download ไฟล์มาพร้อมทั้งเขียนลง Flash อัตโนมัติ
วันจันทร์ที่ 13 ตุลาคม พ.ศ. 2557
MTD command in ASUS RT-N12 Router
Usage: mtd-erase -d part
/ # mtd-unlock
Usage: mtd-unlock -d part
/ # mtd-write
Usage: mtd-write -i file -d part
วันจันทร์ที่ 22 กันยายน พ.ศ. 2557
การหาขา GPIO ของ SoC
1. find ground (like that on the USB port)
2. look for traces coming from the SoC via just one resistor (10K?) and linked to ground: these are most likely unused GPIOs
3. put your multimeter between gnd and the resister (try both sides)
4. try this until you get a reading (change):
(this is for GPIO0)
echo 0 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio0/direction
echo 0 > /sys/devices/virtual/gpio/gpio0/value
echo 1 > /sys/devices/virtual/gpio/gpio0/value
ที่มา








