2015年6月27日 星期六

ubuntu vsftpd






sudo apt-get install vsftpd

vsftpd的相關設定檔:
/etc/vsftpd.conf
/etc/vsftpd.chroot_list

修改設定檔:修改之前記得先備份。
sudo gedit /etc/vsftpd.conf

設定檔中,一些重要的設定說明:
# Allow anonymous FTP? (Disabled by default)
anonymous_enable=NO
是否允許任意使用者連線,預設為=NO,只想給自己使用的就請設為NO

# Uncomment this to allow local users to log in.
local_enable=YES
是否允許本機使用者登入FTP,使用自己的帳號登入者請設為YES

# Uncomment this to enable any form of FTP write command.
write_enable=YES
是否開放寫入的權限,視需求設定,一般開放給自己的就都設為YES

# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
可寫入,且可新增目錄、檔案權限為 775
local_umask=002


chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
關於以上三個設定說明如下:
chroot,就是讓使用者變換根目錄的功能,在登入FTP Server時,預設根目錄為使用者的home directory

chroot_local_user=YES
chroot_list_enable=YES
這樣的設定,讓所有使用者無法變換根目錄,除了/etc/vsftpd.chroot_list中所列的使用者。

都改好了記得要重新啟動vsftpd,才會生效。

sudo /etc/init.d/vsftpd restart


連線進入自己的vsFTPd時,有兩個必要條件,第一個當然電腦要開著,第二個就是要知道自己電腦的IP(有域名的就直接用域名)。

如果您是固定IP上網,要連入自己的vsFTPd就很簡單,但是台灣大多數的連線都是ADSL,是浮動IP,每次上網都會變動,要知道自己電腦上網時的真實IP,可以開啟終端機查詢:
sudo ifconfig


================================================

新增本地使用者+指定登陸瀏覽目錄設定
sudo useradd -d /ex/ex2 -M test
指令說明:新增帳號為test的本地使用者,限制瀏覽目錄於/ex2這個目錄以下,可以往下,無法到上層/ex
sudo passwd test
指令說明:設定本地帳號test使用者的密碼,可新增設定多組使用
sudo useradd -d /ex/ex2 -M test2
sudo passwd test2
若要更改指定目錄則-d後面的/ex/ex2更換即可,但是這個地方須留意的就是權限
/ex這個為上層目錄,上層目錄不能為chomd 777,這樣的話會變成權限過大,vsftpd無法登陸

===============================

疑難雜症

  1. 530 Login incorrect.
    檢查 pam.d/vsftpd 的設定,該註解的要註解掉。另外,auth 及 account 同一行內不可以有註解符號(#)。
  2. 500 OOPS: vsftpd: refusing to run with writable root inside chroot()
    這是因為新版的 vsftpd 限制當啟用chroot時,user的home目錄不可以有寫入的權限,只可以在子目錄下做寫入的動作。google大神上的解法,除了安裝另一個套件(可參考這裡)我沒測試過外,其餘目前測試都無效。所以乖乖把寫入的權限拿掉吧。
    chmod a-w /srv/ftp/user1
    
  3. 226 transfer done (but failed to open directory)
    這是因為目錄沒有x權限的問題,把x權限加上去即可
    chmod a+x /srv/ftp/user1 
    
  4. 550 Failed to change directory
    同226的問題,把x權限加上去即可
    chmod a+x /srv/ftp/user1 

2015年6月26日 星期五

apt-get remove application

sudo apt-get remove application
sudo apt-get remove application*

sudo apt-get remove --purge application
sudo apt-get remove --purge application*

sudo apt-get purge application
sudo apt-get purge application*

2015年6月25日 星期四

ssh-

server:
ssh-keyscan -t rsa 192.168.0.1


client:
past the result in to

/Users/xxx/.ssh/known_hosts


===============
if it is harmless
===============You can use the following one liner to remove that one line (line 3) from the file.
$ sed -i 3d ~/.ssh/known_hosts

2015年6月24日 星期三

list all installed packages

dpkg --get-selections | grep -v deinstall
dpkg-query -l


---------------------------


npm list -g --depth=0
npm list [[@<scope>/]<pkg> ...] npm ls [[@<scope>/]<pkg> ...] npm la [[@<scope>/]<pkg> ...] npm ll [[@<scope>/]<pkg> ...]
---------------------------

disk used


du -shc /home/*
df
df -a
df -h





2015年6月20日 星期六

changing group ownership, group

chgrp groupname groupfile

Changing file ownership

chown peter peterfile

visudo , add user

1_
useradd Example - Add a new user to secondary group

useradd -G {group-name} username

2_
See Which Groups Your Linux User Belongs To
 groups peterd


3_
useradd -G admingroup Username

4_
%admingroup ALL=(ALL) ALL




If you do not see any output then you need to add group developers using the groupadd command:
# groupadd developers
Next, add a user called vivek to group developers:
# useradd -G developers vivek
Setup password for user vivek:
# passwd vivek
Ensure that user added properly to group developers:
# id vivek

usermod example - Add a existing user to existing group

Add existing user tony to ftp supplementary/secondary group with the usermod command using the -a option ~ i.e. add the user to the supplemental group(s). Use only with -G option:
# usermod -a -G ftp tony
In this example, change tony user's primary group to www, enter:
# usermod -g www tony


add user to sudoer

sudo adduser <username> sudo


create directory for user and group

'You will need to create the users directory manually. This requires three steps:
  1. Create directory in compliance to /etc/passwd, usually there will be already a /home/login entry.
  2. Copy initial files from /etc/skel
  3. And finally set right permissions:
    • mkdir /home/YOU
    • cd /home/YOU
    • cp -r /etc/skel/. .
    • chown -R YOU.YOURGROUP .
    • chmod -R go=u,go-w .
    • chmod go= .

Add user with home directory

    useradd -m USERNAME
    passwd USERNAME

2015年6月14日 星期日

airodump, fixed channel -1

方法二
airmon-ng stop wlan0
ifconfig wlan0 down
iwconfig wlan0 mode managed
ifconfig wlan0 up
iwconfig wlan0 channel (这里输入你的channel)
ifconfig wlan0 down
iwconfig wlan0 mode monitor
ifconfig wlan0 up





follow the 18 steps:

https://forums.kali.org/showthread.php?20582-HOW-TO-FIX-Airodump-ng-fixed-channel-1-Kali-kernel-3-12-also-on-rt2870-3070usb

here's how to :
Download backport driver 3.12-1 and extract :
1
Code:
cd /usr/src/
2
Code:
sudo wget https://www.kernel.org/pub/linux/kernel/projects/backports/stable/v3.12/backports-3.12-1.tar.bz2
3
Code:
sudo tar xvf backports-3.12-1.tar.bz2
4
Code:
cd backports-3.12-1
5
Code:
sudo apt-get install patch
download and apply patch
6
Code:
sudo wget http://patches.aircrack-ng.org/mac80211.compat08082009.wl_frag+ack_v1.patch
7
Code:
sudo patch -p1 < mac80211.compat08082009.wl_frag+ack_v1.patch
download compatdrivers_chan_qos_frag.patch by Mathy Vanhoef I recommend using this because I have correct offset
8
Code:
sudo wget -Ocompatdrivers_chan_qos_frag.patch http://www.pastie.org/pastes/8846771/download
9
Code:
patch -p1  < compatdrivers_chan_qos_frag.patch
download my patch
10
Code:
sudo wget -Ofix-channel-negative-1-on-new-backport-by-Devil_D.patch http://pastebin.com/wPwAJaQC
11
Code:
patch -p1  < fix-channel-negative-1-on-new-backport-by-Devil_D.patch
if you do not know what is the proper wireless drivers type and go on step 14 
12
Code:
make old config
13
if you know your driver type for example i have rt2870/3070 i type
make deconfig-wifi To know which driver you just run in terminal airmon-ng 

Code:
make defconfig-alx
make defconfig-ar5523
make defconfig-ath10k
make defconfig-ath5k
make defconfig-ath6kl
make defconfig-ath9k
make defconfig-b43
make defconfig-b43legacy
make defconfig-brcmfmac
make defconfig-brcmsmac
make defconfig-carl9170
make defconfig-drm
make defconfig-ieee802154
make defconfig-iwlwifi
make defconfig-media
make defconfig-nfc
make defconfig-regulator
make defconfig-rtlwifi
make defconfig-wifi
make defconfig-wil6210
14
Code:
make
15
Code:
make install
16
Code:
update-initramfs -u
17
Code:
reboot

I hope it help  Happy Hacking
as always  I apologize for the English mistakes are the fault of google translate 
and I thank the sources
Mathy Vanhoef http://www.mathyvanhoef.com/2012/09/...patch-for.html
Devil_D 
J0K3R-BHS

2015年6月12日 星期五

monitor linux preformance

http://www.tecmint.com/command-line-tools-to-monitor-linux-performance/


1. Top – Linux Process Monitoring

2. VmStat – Virtual Memory Statistics

3. Lsof – List Open Files

5. Netstat – Network Statistics

4. Tcpdump – Network Packet Analyzer

6. Htop – Linux Process Monitoring

7. Iotop – Monitor Linux Disk I/O

8. Iostat – Input/Output Statistics

9. IPTraf – Real Time IP LAN Monitoring

12. NetHogs – Monitor Per Process Network Bandwidth







get information hard ram cpu disk preformance


free -m

CPU
$ cat /proc/cpuinfo
Memory :
$ free
$ cat /proc/meminfo
HDD:
$ df -h
$ sudo fdisk -l
$ hdparm -i /dev/device (for example sda1, hda3...)

command check CPU information

$ less /proc/cpuinfo

2. lscpu

lscpu






2015年6月10日 星期三

parse and node.js install download

npm install node-parse-api

=====================

`-- node_modules
    `-- node-parse-api
        |-- index.js
        |-- lib
        |   `-- Parse.js
        |-- makefile
        |-- package.json
        |-- readme.md
        `-- test
            `-- Parse.test.js

=======================

var Parse = require('./lib/Parse');

var APP_ID='appKey';
var MASTER_KEY='masterKey';

var app = new Parse(APP_ID, MASTER_KEY);

app.insert('Group', { name:'XXX', usedTime:123, usedCount:2343}, function (err, response) {
  console.log(response);
});

/////////////////////////*    below is generating an object with one property

app.insert('Group', { name:'XXX'}, function (err, response) {
  console.log(response);
});

*/////////////////////////


documentation 
https://github.com/Leveton/node-parse-api

2015年6月9日 星期二

bitbucket, sourcetree problem : warning: templates not found /usr/local/git/share/git-core/templates



warning: templates not found /usr/local/git/share/git-core/templates




Steps:
  • Source tree Menu
  • Preferences
  • Git
  • Click on System Git under Embedded Git Version 2.2.1
  • Reset to embedded Git

2015年6月5日 星期五

kali linux enable ssh


Check whether port 22 is listening or not
root@kali:~# netstat -an | grep :22
root@kali:~#
Check the status of ssh service
root@kali:~# service ssh status
[FAIL] sshd is not running … failed!
root@kali:~#
Start ssh service
root@kali:~# service ssh start
[ ok ] Starting OpenBSD Secure Shell server: sshd.
root@kali:~#
Verify the ssh status again
root@kali:~# service ssh status
[ ok ] sshd is running.
root@kali:~#
Check whether port 22 is listening or not


root@kali:~# netstat -an | grep :22
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
root@kali:~#
root@kali:~/Desktop#

adaptable wifi card install

lsusb




Check the driver status

$ lspci -k




Note: If the card is a USB device, running dmesg | grep usbcore should give something like usbcore: registered new interface driver rtl8187 as output.

$ dmesg | grep firmware

$ dmesg | grep iwlwifi