BladeFire Version 0.0.1
1 | #!/usr/bin/env python |
1 | #!/usr/bin/env python |
error Like this:
└─(14:11:27)──> python -c “import MySQLdb” ──(一, 725)─┘
Traceback (most recent call last):
File “
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQLdb/init.py”, line 19, in
import _mysql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so
Reason: image not found
add the following stuff to your .bash_profile
mine is .zshrc
1 | export DYLD_LIBRARY_PATH=/usr/local/mysql-5.6.27-osx10.8-x86_64/lib:$DYLD_LIBRARY_PATH |
“/usr/local/mysql-5.6.27-osx10.8-x86_64/lib “ is my mysql location on OS X,
replace yours, and you will import the mysqldb successfully.
1 | import socket |
Running this script,we will get the basic info about our machine
1 | import socket |
The Python socket library has utilities to deal with the various
IP address format.Here,we will use two of them:inet_aton() and
inet_ntoa()
1 | import socket |
SAMBA:
SAMBA CLIENT ALL:
install SAMBA:
bos.cifs_fs.5.3.0.0.I
bos.cifs_fs.rte.5.3.0.62.U
smitty cifs_fs
lscifsmnt
rmcifsmnt -f /smb_mnt
mkcifsmnt -f /mnt -d share1 -h server1 -c user1
smitty cifs_fs:
first it will do in read-only, later have to come back again and set it again
If Share name is like this: \server name\share name, it is enough to write “share name” (\server.. not needed)
[Entry Fields]
or both
/etc/filesystems entry will mount on start [no]After these the credential file has to be set as well:
smitty cifs_fs -> Credential configuration
/etc/cifs_fs/cifscred file allows future mounting of CIFS shares with stored credentials
lscifscred lists the server or user entries stored in the /etc/cifs_fs/cifscred file (mkcifscred, rmcifscred, chcifscred)
other methods:
/usr/sbin/mkcifsmnt -t rw -f /homes/ftp/29/test -d test -h 10.10.15.24 -c SSG01 -p xyz -u 32292 -g 6000116 -x 777
mount -v cifs -n 10.10.15.24/SSG01/xyz -o uid=32292,gid=200,fmode=775 test /homes/ftp/29/test
Once on Win side had to change something in order to work:
“I have changed something on the server - from “Send NTLMv2 response only. Refuse LM NTLM” to “ Send LM & NTLM - use NTLMv2 session security if negotiated” So I hope, this fixes the problem”
SAMBA SERVER ALL:
Needed ports:
netbios-ns 137/tcp # NETBIOS Name Service
netbios-ns 137/udp # NETBIOS Name Service
netbios-dgm 138/tcp # NETBIOS Datagram Service
netbios-dgm 138/udp # NETBIOS Datagram Service
netbios-ssn 139/tcp # NETBIOS Session Service
netbios-ssn 139/udp # NETBIOS Session Service
microsoft-ds 445/tcp # Microsoft-DS
microsoft-ds 445/udp # Microsoft-DS
netbios is Windows file & printer sharing
Microsoft-DS (Microsoft Directory Services) is a port used for file sharing. It was introduced with Windows 2000 and gives you the possibility to use SMB protocol (stands for Server Message Block, but is also known as Samba) directly over TCP-IP on port 445.
In www.samba.org, written this:
UDP/137 - used by nmbd
UDP/138 - used by nmbd
TCP/139 - used by smbd
TCP/445 - used by smbd
INSTALL:
/mnt/MISC/SAMBA
-rwxrwxrwx 1 root sys 67379200 Jun 28 2005 samba-3.0.4.0.bff
smitty install:
root@aix31: /mnt/MISC/SAMBA # lslpp -l | grep -i samba
freeware.samba.rte 3.0.4.0 COMMITTED Samba Version 3.0.4
SWAT (SAMBA Web Administartion Tool) configuration: (not necessary, only if you want it)
It is a GUI for SAMBA, a web browser is needed for SWAT, and X11 as well.
/etc/services:
swat 901/tcp
/etc/inetd.conf:
swat stream tcp nowait root /usr/local/samba/sbin/swat swat
in browser:
SAMBA tools:
install dir: /usr/local/samba
/usr/local/samba/sbin/nmbd <–provides netbios nameserver supports to clients (nameserver for samba)
/usr/local/samba/sbin/smbd <–smb daemon
/usr/local/samba/sbin/smbd -b <–shows configuration infos. i.e.: path for the config file: smbd -b|grep smb.conf
/usr/local/samba/bin/smbstatus <–shows actual sharings and connections
/usr/local/samba/bin/testparm <–test the smb.conf file for any typo
/usr/local/samba/bin/pdbedit -a user123 <–creates users (on AIX I created before)
/usr/local/samba/bin/smbpasswd <–changes pw (-a: add a user who can access the shares from a client)
/usr/local/samba/bin/smbclient <–it is an SMB client program for UNIX machines, it provides an ftp like interface,
to transfer files between a windows 'server' and a unix 'client'
PROCESS OF SAMBA CONFIGURATION:
check ports: a 137,138,139,445 (if needed firewall opening)
rpcinfo, telnet
check where is smb.conf:
/usr/local/samba/sbin/smbd -b <–shows version of SAMBA etc.,and the path to smb.conf
edit smb.conf:
/usr/local/samba/lib/smb.conf (it is a link to /etc/samba/smb.conf)
Create a similar entry:
[samba_share] <–use this name for connection
comment = share test <–anything can be written here
path = /home/samba_share <–path of the dir what we want to share
read only = no
guest ok = yes
read list = user123 <–users who will be able to read it (space separated)
write list = user123 <–users who will be able to write to it (space separated)
Important:
-check owner,rights of the given directory (in the path)
-after chacnging the conf file, daemons have to be restarted in order changes be refreshed
this is good for read only:
[samba_share]
comment = share test
path = /home/samba_share
read only = no
3.SAMBA user creation:
/usr/local/samba/bin/smbpasswd -a user123 <– -a: add user as well
Same user has to be created, to what we gave in the conf file
For root we can create one:
/usr/local/samba/bin/smbpasswd -a root
(root passw is needed)
testing not the default conf file:
/usr/local/samba/bin/testparm /etc/samba/smb.conf
starting daemons:
/usr/local/samba/sbin/smbd -D <– -D: handling it as daemon (this is the default)
/usr/local/samba/sbin/nmbd -D
connecting to SAMBA:
LOCALLY (AIX):
/usr/local/samba/bin/smbclient //localhost/samba_share <–samba_share: which has been created in conf file
password is what has been created with smbpasswd for the user
if not root user, than check permissions of the conf file (if needed give read permission)
another way: /usr/local/samba/bin/smbclient -U% -L localhost
REMOTELY (WINDOWS):
(tools->map network drive->choose a drive)
the command: \10.10.101.78\samba_share <–it will map that directory
“Connect using a different username”: If on Windows and AIX users are identical this is not needed.
If user/pw created in SAMBA is different of the actual windows user/pw, then here we can give the SAMBA user/pw.
/usr/local/samba/bin/smbclient -L 10.10.101.78 <–shows which shares are available on a given host
!!!2 different SAMBA version (rpm and a fileset one) should no be installed at the same time (daemons did not started for me)!!!!
I had this error:
(Samba was installed from rpm and it was started from inetd.)
added interface ip=10.10.10.8 bcast=10.10.35.31 nmask=255.255.255.224
session request to LOCALHOST failed (Call returned zero bytes (EOF)
)
session request to *SMBSERVER failed (Call returned zero bytes (EOF)
)
check samba logs (I turned this on)
vi /etc/inetd.conf: netbios-ssn stream tcp nowait root /usr/sbin/smbd -l /var/log/samba.log smbd
refresh -s inetd
(probably in syslog you can find where it is logging)
cat samba.log
…
[2012/10/11 09:20:11, 0] tdb/tdbutil.c:tdb_log(531)
tdb(/etc/secrets.tdb): rec_free_read bad magic 0x2f73616d at offset=812 <–shows problems with /etc/secrets.tdb
[2012/10/11 09:20:11, 0] passdb/machine_sid.c:pdb_generate_sam_sid(163)
pdb_generate_sam_sid: Failed to store generated machine SID.
[2012/10/11 09:20:11, 0] smbd/server.c:main(793)
ERROR: Samba cannot create a SAM SID.
stop samba
vi /etc/inetd.conf -> comment lines smbd, nmbd
refresh -s inetd
remove /etc/secrets.tdb
mv /etc/secrets.tdb /etc/secrets.tdb.old
start samba
vi /etc/inetd.conf -> uncomment smbd, nmbd lines
refresh -s inetd
test login
added interface ip=10.10.10.8 bcast=10.10.35.31 nmask=255.255.255.224
Password:
I had this “error”:
Samba version 2.2.7
Failed to open byte range locking database
ERROR: Failed to initialise locking database
Can’t initialise locking module - exiting
This is not an error after first successful login it will be OK.
I did: smbclient -L localhost -U
After that: smbstatus
Samba version 2.2.7
No locked files
zlib 安装的版本是1.2.8,源代码可以从zlib的官网上下载
Zlib
基本的步骤都是解包,然后./configure make && make install
这个步骤稍微复杂,我遇到一个错误,找到问题修改了源代码中几个地方
从openssh包中找到一个叫做sshbuf-getput-basic.c 的C文件
用VI编辑器打开,从代码中将所有va_copy替换成VA_COPY,我们可以使用vi编辑器
快捷键实现批量替换,%s?va_copy?VA_COPY,完成之后在代码宏定义下面加入
下面条件语句.
1 | #ifndef VA_COPY |
全部修改完毕后,进行./configure,然后没有报错就可以进项make && make install
我这边的openssl没有升级,因为之前有安装过openssh所以一些依赖关系存在,还有
C编译器在我这边的AIX6里面是安装的,如果遇到无法gcc需要额外安装gcc编译器
Hope u enjoy!
pam-devel openssl-devel zlib-devel krb5-devel
Zlib 1.1.4 or 1.2.1.2 or greater
1 | rpm -e `rpm -qa | grep openssl` --allmatches -nodeps |
tar -xzvf [Packege name]
注意参数
注意使用root权限
(1)./config –prefix=/usr –shared
注意,一定要加上–shared选项,否则openssh编译时候会找不到openssl的
library
这部我这边出现了一个make depend报警,忽略即可
(2)安装
make && make install
(3)验证安装是否成功
openssl version -a
1 | (1)配置 |
1 | #!/usr/bin/env python |
we need to install builtwith first1
2import builtwith
builtwith.parse('http://example.webscrapying.com')
we can get the following information:
{u’javascript-frameworks’: [u’jQuery’, u’Modernizr’, u’jQuery UI’],
u’web-frameworks’: [u’Web2py’, u’Twitter Bootstrap’],
u’programming-languages’: [u’Python’], u’web-servers’: [u’Nginx’]}
This module will take a URL,download and analyze it, and then return
the technologies used by the website.
You need to install the module named python-whois
pip install python-whois
1 | import whois |
print whois.whois(‘weibo.com’)
print whois.whois(‘weibo.com’)
{
“updated_date”: [
“2016-03-20 00:00:00”,
“2016-03-20 14:56:29”
],
“status”: [
“clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited“,
“clientTransferProhibited https://icann.org/epp#clientTransferProhibited“,
“clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited“
],
“name”: “Beijing Weibo Internet Technology Co.,Ltd”,
“dnssec”: “unsigned”,
“city”: “Bei jing”,
“expiration_date”: [
“2026-03-20 00:00:00”,
“2111-03-20 04:00:00”
],
“zipcode”: “100080”,
“domain_name”: [
“WEIBO.COM”,
“weibo.com”
],
“country”: “CN”,
“whois_server”: “whois.35.com”,
“state”: “Bei jing”,
“registrar”: “35 Technology Co., Ltd.”,
“referral_url”: “http://www.35.com“,
“address”: “Ideal Int’l Plaza, No. 58, West Of North Forth Ring Rd”,
“name_servers”: [
“NS1.SINA.COM.CN”,
“NS2.SINA.COM.CN”,
“NS3.SINA.COM”,
“NS3.SINA.COM.CN”,
“NS4.SINA.COM”,
“NS4.SINA.COM.CN”,
“ns1.sina.com.cn”,
“ns2.sina.com.cn”,
“ns3.sina.com.cn”,
“ns4.sina.com.cn”,
“ns3.sina.com”,
“ns4.sina.com”
],
“org”: “Beijing Weibo Internet Technology Co., Ltd.”,
“creation_date”: [
“1999-03-20 00:00:00”,
“1999-03-20 04:00:00”
],
“emails”: [
“abuse@35.cn”,
“domainname@staff.sina.com.cn”
]
}
1 | #!/usr/bin/env python |
Switches like other computers have a limited size of member that’s also true for the table
holding MAC address information used by the switch to remember which MAC is on which port
as well as its internal ARP cache.Sometimes switches react a bit weirdly if their buffers
overflow. This can lead from denial of service up to giving up switching and behaving like
a normal hub. In hub mode the overall higher traffic raise is not the only problem you would
hav thus all connected computers could see the complete traffic without additional actions.
You should test how your switches react on these exceptions and that’s what the next script is
good for.It generates random MAC addresses and sends them to your switch until the buffer is full
1 | #!/usr/bin/env python |
:) life is short, so use python!