顯示具有 Ubuntu 標籤的文章。 顯示所有文章
顯示具有 Ubuntu 標籤的文章。 顯示所有文章

2018年3月14日 星期三

2016年5月16日 星期一

[Ubuntu] Miniupnp installation

  • Install Package
    • apt-get install libssl-dev
    • apt-get install iptables-dev
  • Start to compile
    make -f Makefile.linux
  • Execute miniupnpd
  • root@freeman-laptop:/home/freeman/test1/miniupnpd-1.9.20160222# ./miniupnpd
    Usage:
            ./miniupnpd [-f config_file] [-i ext_ifname] [-o ext_ip]
                    [-a listening_ip] [-p port] [-d] [-U] [-S] [-N]
                    [-u uuid] [-s serial] [-m model_number] 
                    [-t notify_interval] [-P pid_filename] 
                    [-B down up] [-w url] [-r clean_ruleset_interval]
                    [-A "permission rule"] [-b BOOTID]
    
    Notes:
            There can be one or several listening_ips.
            Notify interval is in seconds. Default is 30 seconds.
            Default pid file is '/var/run/miniupnpd.pid'.
            Default config file is '/etc/miniupnpd.conf'.
            With -d miniupnpd will run as a standard program.
            -S sets "secure" mode : clients can only add mappings to their own ip
            -U causes miniupnpd to report system uptime instead of daemon uptime.
            -N enables NAT-PMP functionality.
            -B sets bitrates reported by daemon in bits per second.
            -w sets the presentation url. Default is http address on port 80
            -A use following syntax for permission rules :
              (allow|deny) (external port range) ip/mask (internal port range)
            examples :
              "allow 1024-65535 192.168.1.0/24 1024-65535"
              "deny 0-65535 0.0.0.0/0 0-65535"
            -b sets the value of BOOTID.UPNP.ORG SSDP header
            -h prints this help and quits.
    

Reference:
  1. [miniupnpd] miniupnpd 的 uPnP daemon使用

2015年9月7日 星期一

2015年7月28日 星期二

[Linux] PPPOE build up settings

1.
vim /etc/ppp/pppoe-server-options

require-chap
lcp-echo-interval 10
lcp-echo-failure 2
ms-dns 8.8.8.8
ms-dns 8.8.4.4
netmask 255.255.255.0
defaultroute
noipdefault
usepeerdns

2.
vim /etc/ppp/chap-secrets

# Secrets for authentication using CHAP
# client    server  secret          IP addresses

# "aliens"  *   "changeme"  *
aliens  *   changeme    *

3.
method1:
echo “192.168.1.1-20” > /etc/ppp/allip

method2:
echo “10.10.10.1-20” > /etc/ppp/allip

4. Execute binary
method1:
pppoe-server -L 192.168.1.254 -p /etc/ppp/allip -I eth2

method2:
pppoe-server -L 10.10.10.254 -p /etc/ppp/allip -I eth2

Reference:

2015年6月29日 星期一

[OpenVPN] How to set up openvpn

Ubuntu 10.04 - Install Server on it
Install openvpn
sudo apt-get install openvpn easy-rsa

Server - Generate (Public Key Infrastructure)
0. Download easy-rsa from internet.
easy-rsa download point
tar xvf easy-rsa-2.2.0_master.tar.gz
cd easy-rsa-2.2.0_master/easy-rsa/2.0

1. Copy easy-rsa script to the folder of /etc/openvpn
mkdir /etc/openvpn/easy-rsa/
cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0/* /etc/openvpn/easy-rsa/
cp -r /usr/share/doc/openvpn/examples/sample-config-files/ /etc/openvpn/

2. edit /etc/openvpn/easy-rsa/vars
This is for server environment
export KEY_COUNTRY="US"
export KEY_PROVINCE="NC"
export KEY_CITY="Winston-Salem"
export KEY_ORG="Example Company"
export KEY_EMAIL="steve@example.com"

3. Generate the master Certificate Authority (CA) certificate and key
cd /etc/openvpn/easy-rsa/
source vars

# This command will create index.txt(empty) and serial(01) under the folder of keys.
./clean-all
# This script will create ca.crt.
# This is common one for server and client site.
# ca.crt privilege is 644
./build-ca

4. Generate a certificate and private key for the server
# key privilege is 600(Private CA key)
# crt privilege is 644 (Public CA key)
./build-key-server myservername

5. Diffie Hellman parameters must be generated for the OpenVPN server
# dh1024.pem privilege is 644
./build-dh

6. Copy related file to /etc/openvpn/
cp myservername.crt myservername.key ca.crt dh1024.pem /etc/openvpn/



Server Startup
1. Copy server.conf to /etc/openvpn
sudo cp /etc/openvpn/sample-config-files/server.conf.gz /etc/openvpn/
sudo gzip -d /etc/openvpn/server.conf.gz

2. Make sure the following info is correct relate your file.

ca ca.crt
cert myservername.crt
key myservername.key
dh dh1024.pem


3. Startup openvpn
method 1
/etc/init.d/openvpn is a script
/etc/init.d/openvpn start
method 2
/usr/sbin/openvpn --config /etc/openvpn/server.conf

Successful log at the end of page

4. check tun0 appear on computer
ifconfig


Client - Generate (Public Key Infrastructure)
1. Create Client Certificates on ubuntu 10.04
cd /etc/openvpn/easy-rsa/
source vars
./build-key client1

2. Copy following file to client
ca.crt client1.crt client1.key



Windows XP - OpenVPN install
1. Install OpenVPN tools for windows XP
Install OpenVPN for windows.

2. Watch Youtube - Tutorial - How to install, configure and connect with the OpenVPN client will know how to use windows client of openvpn.

Reference:
Server command :
/etc/openvpn/openvpn --cd /etc/openvpn/server1 --config config.ovpn
--cd directory


Start Server successful log at following

Fri Sep 18 11:39:04 2015 OpenVPN 2.3.2 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [eurephia] [MH] [IPv6] built on Dec  1 2014
Fri Sep 18 11:39:04 2015 Diffie-Hellman initialized with 1024 bit key
Fri Sep 18 11:39:04 2015 Socket Buffers: R=[212992->131072] S=[212992->131072]
Fri Sep 18 11:39:04 2015 ROUTE_GATEWAY 111.2.1.252/255.255.255.0 IFACE=eth0 HWADDR=08:00:27:4f:b5:fc
Fri Sep 18 11:39:04 2015 TUN/TAP device tun0 opened
Fri Sep 18 11:39:04 2015 TUN/TAP TX queue length set to 100
Fri Sep 18 11:39:04 2015 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Fri Sep 18 11:39:04 2015 /sbin/ip link set dev tun0 up mtu 1500
Fri Sep 18 11:39:04 2015 /sbin/ip addr add dev tun0 local 10.8.0.1 peer 10.8.0.2
Fri Sep 18 11:39:04 2015 /sbin/ip route add 10.8.0.0/24 via 10.8.0.2
Fri Sep 18 11:39:04 2015 UDPv4 link local (bound): [undef]
Fri Sep 18 11:39:04 2015 UDPv4 link remote: [undef]
Fri Sep 18 11:39:04 2015 MULTI: multi_init called, r=256 v=256
Fri Sep 18 11:39:04 2015 IFCONFIG POOL: base=10.8.0.4 size=62, ipv6=0
Fri Sep 18 11:39:04 2015 IFCONFIG POOL LIST
Fri Sep 18 11:39:04 2015 Initialization Sequence Completed

2015年6月17日 星期三

[ubuntu 10.04] Install pptpd and settings


0. compile package
ppp-2.4.5.tar.gz & pptpd-1.3.4.tar.gz
GitHub - Linux_Cross_Compiler_tools

configure pptpd and ppp
1. sudo gedit /etc/pptpd.conf

option /etc/ppp/pptpd-options
localip 10.10.0.1
remoteip 10.10.0.2-10

2. sudo gedit /etc/ppp/pptpd-options
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8
ms-dns 8.8.4.4
proxyarp
nodefaultroute
lock
nobsdcomp
debug
dump

3. sudo gedit /etc/ppp/chap-secrets
aliens * changeme *

4. start pptpd
# -d = debug
sudo pptpd -d




Reference:
- How to install a VPN Server (PPTP) on Debian/Ubuntu Linux VPS
- Ubuntu 11.10 架設 pptp server (VPN server) & Win 7 pptp client 連線設定
- HOWTO: Setting up a vpn using ssh and pppd
- PPTPServer

Debug:
- PPTP Client - Diagnosis HOWTO
- [PPTPD]VPN解决PTY read or GRE write failed问题

Embedded kernel module:
ppp_mppe
ip_gre


Sever can let both client go to internet

iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

The command below for reference, because ppp+ can represent for multiple ppp0 ppp1 ppp2 ....

iptables -I INPUT -s 10.10.0.0/24 -i ppp+ -j ACCEPT

Two Client can ping to each other

iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
iptables -A FORWARD -i ppp0 -o eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth2 -o ppp0 -j ACCEPT
route del default eth2
route add default ppp0

2015年2月9日 星期一

[metasploit] Install metasploit on ubuntu 12.04

apt-get update
apt-get upgrade

apt-get -y install build-essential libreadline-dev libssl-dev libpq5 libpq-dev libreadline5 libsqlite3-dev libpcap-dev openjdk-7-jre subversion git-core autoconf postgresql pgadmin3 curl zlib1g-dev libxml2-dev libxslt1-dev vncviewer libyaml-dev ruby1.9.3

gem install wirble sqlite3 bundler

git clone https://github.com/rapid7/metasploit-framework.git /opt/metasploit-framework

cd /opt/metasploit-framework

bundle install

bash -c 'for MSF in $(ls msf*); do ln -s /opt/metasploit-framework/$MSF /usr/local/bin/$MSF;done'




Q :/home/vagrant/metasploit-framework/lib/metasploit/framework.rb:19:in `require': cannot load such file -- robots (LoadError)
A : 
vagrant@precise64:/$ ls -al  ./var/lib/gems/1.9.1/gems/robots-0.10.1/lib/robots.rb
-rw-r----- 1 root root 3174 Dec 23 03:19 ./var/lib/gems/1.9.1/gems/robots-0.10.1/lib/robots.rb

vagrant@precise64:/$ sudo chmod a+r  ./var/lib/gems/1.9.1/gems/robots-0.10.1/lib/robots.rb

vagrant@precise64:/$ ls -al  ./var/lib/gems/1.9.1/gems/robots-0.10.1/lib/robots.rb
-rw-r--r-- 1 root root 3174 Dec 23 03:19 ./var/lib/gems/1.9.1/gems/robots-0.10.1/lib/robots.rb



Usage :
1. Into msf
msfconsole

2. Check cookie
msf > use auxiliary/scanner/http/allegro_rompager_misfortune_cookie

msf auxiliary(allegro_rompager_misfortune_cookie) > show actions Auxiliary actions: Name Description ---- -----------
msf auxiliary(allegro_rompager_misfortune_cookie) > show options Module options (auxiliary/scanner/http/allegro_rompager_misfortune_cookie): Name Current Setting Required Description ---- --------------- -------- ----------- Proxies no Use a proxy chain RHOSTS 192.168.0.1 yes The target address range or CIDR identifier RPORT 80 yes The target port TARGETURI /Allegro yes Path to fingerprint RomPager from THREADS 1 yes The number of concurrent threads VHOST no HTTP server virtual host

msf auxiliary(allegro_rompager_misfortune_cookie) > set RPORT 80 RPORT => 80
msf auxiliary(allegro_rompager_misfortune_cookie) > run [*] Scanned 1 of 1 hosts (100% complete) [*] Auxiliary module execution completed
Reference:
1. The Quest for Automated Interrogation pt 3
2. Allegro Software RomPager 'Misfortune Cookie' (CVE-2014-9222) Scanner

2015年1月25日 星期日

2015年1月19日 星期一

[Ubuntu] Make deb package and own local package repository

1. write a c code
#include <stdio.h>

int main()
{
   printf("happy.org\n");

    return 0;
}


2. Compile c code
gcc happy.c -o happy


3. Creating a Debian package
$ mkdir happy-0.0.1/DEBIAN -p


4. Edit control file
$ vim happy-0.0.1/DEBIAN/control
Package: happy
Version: 0.0.11
Section: custom
Priority: optional
Architecture: all
Essential: no
Installed-Size: 1024
Maintainer: happy.org
Description: Print happy.org on the screen


5. Copy binary file into happy-0.0.1/usr/bin/
$ mkdir  happy-0.0.1/usr/bin/ -p
$ cp happy happy-0.0.1/usr/bin/


6. Create a debian package.
dpkg-deb –build happy-0.0.1

  1. Remove debian package
    dpkg -P happy-0.0.1

Make own reporsitory

1. Install apache
sudo apt-get install apache2 apache2-doc apache2-utils
$ mkdir cd /var/www/debian


2. copy deb package to /var/www/debian
cp /path/to/happy-0.0.1.deb /var/www/debian/


3. Create a package list using dpkg-scanpackages
$ dpkg-scanpackages debian /dev/null | gzip -9c > debian/Packages.gz
dpkg-scanpackages: warning: Packages in archive but missing from override file:
dpkg-scanpackages: warning:   happy-0.0.1
dpkg-scanpackages: info: Wrote 1 entries to output Packages file.

4. Upload the folder of debian you web sever on internet
scp /var/www/debian xxx@123.123.123.123:/var/www

5. Add new repository address to local list
echo “deb http://123.123.123.123 debian/” >> /etc/apt/sources.list
apt-get update


6. Install happy-0.0.1 package
sudo apt-get install linuxconfig




Reference:
1. Easy way to create a Debian package and local package repository
2. [Raspberry pi] Install LAMP

2015年1月16日 星期五

[QEMU][Raspberry Pi] Building With QEMU User Mode Emulation

In user mode, only the ARM CPU is emulated and your real file system is used as storage.
1.
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
cat /proc/sys/fs/binfmt_misc/status
If it says enabled, you’re good to go.


2. create a directory to hold your chroot environment:
export LFS=/lfs
mkdir $LFS
cd $LFS
wget http://circu.it/pilfs/ch5-tools-20141203.tar.xz
tar xvf ch5-tools-20141203.tar.xz


3. Install qemu to get qemu-arm binary
apt-get install qemu binfmt-support qemu-user-static


Copy qemu-arm-static to Emulation system.

mkdir -pv $LFS/usr/bin
cp -v /usr/bin/qemu-arm-static $LFS/usr/bin

4. Make a wrapper binary that will call qemu-arm-static with the correct arguments to emulate the same CPU family and kernel version as that of a Raspberry Pi.

wget http://www.intestinate.com/pilfs/patches/qemu-arm-wrapper.c
gcc -static qemu-arm-wrapper.c -s -o qemu-arm-wrapper
cp -v qemu-arm-wrapper $LFS/usr/bin

5. Register a binfmt_misc handler for our ARM binaries

echo ":arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-wrapper:" > /proc/sys/fs/binfmt_misc/register

6. trying to chroot into your /lfs directory:
chroot "$LFS" /tools/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin /tools/bin/bash --login +h

7. See a prompt that reads “I have no name!”, everything is working correctly.

Reference:

1. QEMU User Emulation
2. Linux From Scratch on the Raspberry Pi

2015年1月12日 星期一

[Latex][Archlinux] latex to compile yzu_thesis_latex_v203 without issue

Archlinux :
pacman -S –noconfirm texlive-most
pacman -S –noconfirm texlive-lang


Ubuntu :
sudo apt-get –yes –force-yes install texlive-xetex
sudo apt-get –yes –force-yes install latex-cjk-all
sudo apt-get –yes –force-yes install texlive
sudo apt-get –yes –force-yes install texlive-publishers


Then latex xxx and bibtex xxx will no problem


Reference:

2015年1月7日 星期三

[tmux] function list

Modify windows name :
C-b + , = rename-window
C-b + . = Modify WindowNumber
C-b + & = kill-window
     C-b: send-prefix      
     C-o: rotate-window
     C-z: suspend-client
   Space: next-layout
       !: break-pane
       ": split-window
       #: list-buffers
       %: split-window -h
       &: confirm-before kill-window
       ': select-prompt
       ,: command-prompt "rename-window '%%'"       -: delete-buffer
       .: command-prompt "move-window -t '%%'"       0: select-window -t :0       1: select-window -t :1       2: select-window -t :2       3: select-window -t :3       4: select-window -t :4       5: select-window -t :5       6: select-window -t :6       7: select-window -t :7       8: select-window -t :8       9: select-window -t :9       :: command-prompt
       ?: list-keys
       D: choose-client
       [: copy-mode
       ]: paste-buffer
       a: send-prefix
       c: new-window
       d: detach-client
       f: command-prompt "find-window '%%'"       i: display-message
       l: last-window
       n: next-window
       o: down-pane
       p: previous-window
       q: display-panes
       r: refresh-client
       s: choose-session       t: clock-mode
       w: choose-window
       x: confirm-before kill-pane
       {: swap-pane -U
       }: swap-pane -D
       ~: show-messages
   PPage: copy-mode -u
      Up: up-pane
    Down: down-pane
     M-1: select-layout even-horizontal
     M-2: select-layout even-vertical
     M-3: select-layout main-horizontal
     M-4: select-layout main-vertical
     M-n: next-window -a
     M-o: rotate-window -D
     M-p: previous-window -a
    M-Up: resize-pane -U 5  M-Down: resize-pane -D 5  M-Left: resize-pane -L 5 M-Right: resize-pane -R 5    C-Up: resize-pane -U
  C-Down: resize-pane -D
  C-Left: resize-pane -L
 C-Right: resize-pane -R

2014年12月31日 星期三

[tmux] Send command to tmux

show tmux session
tmux list-session
0: 2 windows (created Tue Feb 3 11:25:52 2015) [179x47]

tmux attach -t session_name
ex :
tmux attach -t 0

tmux kill-session -t session_name
ex :
tmux kill-session -t 0

panel [4]
Show panel number
ctrl+b q


Send command to tmux
tmux send -t 0 ls ENTER

Reference:
1. Run command in detached tmux session
2. A tmux Crash Course
3. man tmux 4. tmux shortcuts & cheatsheet 5. Terminal Multiplexers: Screen, Tmux

2014年12月22日 星期一

2014年12月19日 星期五

[samba] Install samba on ubuntu 14.10

1.Install samba
sudo apt-get install samba samba-common python-glade2 system-config-samba
2.Backup the configuration file of samba
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
3.Edit the configuration file of samba
sudo vim /etc/samba/smb.conf
[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = ubuntu
security = user
map to guest = bad user
dns proxy = no
#============================ Share Definitions ============================== 
[Anonymous]
path = /home/happy
browsable =yes
writable = yes
guest ok = yes
read only = no

[global]
workgroup = MYGROUP
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 50
security = user
passdb backend = tdbsam

load printers = yes
cups options = raw

guest account = rober

follow symlinks = yes
wide links      = yes
unix extensions = no


[homes]
comment = Home Directories
browseable = yes
writable = yes
;       valid users = %S
;       valid users = MYDOMAIN\%S

4.Restart samba
sudo service smbd restart
Reference:
  1. mba Server Configuration in Ubuntu 14.04 LTS

2014年12月14日 星期日

[SCSS] Using SCSS to quick produce the CSS

1. Build the environment
Quick to build up the environment of Ruby on Rails. Please refer the following blog.
[Vagrant] Using virtual machine to quick implement Ruby on Rails
2.Install compass
Updating the ruby environment
    $ gem update --system
    $ gem install compass
3.Create the project
compass create
4.Create a new file was called style.sass
.body
        display: none


.container
        background: red
        input
                font-size: 12px
5.Compile the style.sass
sass –watch
Reference :
1.CSS with superpowers
2.使用scss來加速寫css吧!

2014年12月13日 星期六

[Vagrant] Using virtual machine to quick implement Ruby on Rails


host $ git clone https://github.com/rails/rails-dev-box.git
host $ cd rails-dev-box
host $ vagrant up
What’s In The Box
Development tools
Blockquote
Git
Ruby 2.1
Bundler
SQLite3, MySQL, and Postgres
Databases and users needed to run the Active Record test suite
System dependencies for nokogiri, sqlite3, mysql, mysql2, and pg
Memcached
Redis
RabbitMQ
An ExecJS runtime
Reference:
1. A Virtual Machine for Ruby on Rails Core Development