2023年8月23日 星期三

 Ubuntu has a mechanism, that is, the installed network card (NIC) will be renamed to another name when the system is booted. Although there is no difference in using it, it is just a little unaccustomed. After booting, we can observe the dmesg log as follows

dmesg | grep rename

You can see that the following network cards eth0 and eth1 have been renamed to ens160 and ens192:

[1.341871] vmxnet3 0000:03:00.0 ens160: renamed from eth0

[1.362582] vmxnet3 0000:0b:00.0 ens192: renamed from eth1

The method of closing is very simple, that is, edit the /etc/default/grub file and change the following parameters:

GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

Update grub.cfg with the following command

sudo update-grub

change interface configure

/etc/network/interfaces

error message : configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: "%)']/following::android.widget.EditText"

 In general analysis, the last sentence is the key point: When reading the configuration file config.ini, there are % caused by

 

Solution one:

Most likely configparser is reading the literal "%" sign in the string. The '%' symbol is used for string interpolation (substitution). If you want to use a literal "%", you can escape it with another "%". For example, use "100%%" to mean "100%" in configuration variables read by configparser.

Solution two:

Change from

cf= configparser.ConfigParser()

to

cf = configparser.RawConfigParser()

2022年12月13日 星期二

OSError: [Errno 22] Invalid argument:

1Error message :


File "tarfile.py", line 2155, in makefile with bltn_open(targetpath, "wb") as target:

 OSError: [Errno 22] Invalid argument:


 This looks like a windows problem as colons in filenames are reserved characters in Windows. We don't like the idea of renaming the actual file for the sake of supporting in Windows. We will look into alternatives and track this as an enhancement separately. 

2. Edit tarfile.py :


 You should add a line in 2155 

# targetpath_s = targetpath.replace(':','-')



2021年3月11日 星期四

Change NAS password on Win10

 

win+R打開執行,輸入control userpasswords2,會變這樣


再按到進階,管理密碼,windows認證,就可以選要把哪條密碼清除了






 

2021年1月19日 星期二

Esxi increase hard drive size (Ubuntu none LVM)

1 Install parted if you don't have them using 

CI-Server:~$ sudo apt-get install cloud-guest-utils


2. Turn off swap. we gonna remove it's partition!
CI-Server:~$ sudo swapoff -a
CI-Server:~$ sudo parted
get partitions list with print all:
(parted) print all
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 752GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End    Size    Type      File system     Flags
1      1049kB  528GB  528GB   primary   ext4            boot
2      528GB   537GB  8588MB  extended
5      528GB   537GB  8588MB  logical   linux-swap(v1)
remove none root partitions with rm (part-index):

(parted) rm 5
Warning: Partition /dev/vda5 is being used. Are you sure you want to continue?
Yes/No? yes
Error: Partition(s) 5 on /dev/vda have been written, but we have been unable to
inform the kernel of the change, probably because it/they are in use.  As a
result, the old partition(s) will remain in use.  You should reboot now before
making further changes.
Ignore/Cancel? C
(parted) print all
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 752GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End    Size    Type      File system  Flags
 1      1049kB  528GB  528GB   primary   ext4         boot
 2      528GB   537GB  8588MB  extended

(parted) rm 2
Error: Partition(s) 5 on /dev/vda have been written, but we have been unable to
inform the kernel of the change, probably because it/they are in use.  As a
result, the old partition(s) will remain in use.  You should reboot now before
making further changes.
Ignore/Cancel? C
(parted) print all
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 752GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End    Size   Type     File system  Flags
 1      1049kB  528GB  528GB  primary  ext4         boot
The commands works on ubuntu 16.04 (NONE LVM) and machine is running on a kvm:

sudo growpart /dev/vda 1
sudo resize2fs /dev/vda1  


How to set /etc/issues to show the IP address of eth0


linux virtual machines with a bridge interface, and I want to display the machine's IP address after the machine is booted (in login, it usually shows the release and kernel).

This is just a text file...you write it in the same way you would send text to the file using any other shell script. Something like this will replace /etc/issue with your ip address:

  1. ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -f2 -d: > /etc/issue


Obviously, depending on the information you want in /etc/issue, you can make this more complex file at will.

You can write to this file using the local equivalent /etc/rc.d/rc.local (usually executed after all other startup scripts).


On CentOS 7 and Debian 8, just append the following line to /etc/issue

  1. My IP address: \4


This will resolve to the machine’s IPv4 address. If you have multiple network interfaces and want to select a specific network interface, you can use specify it

  1. My IP address: \4{eth0}


Check man getty for the list of escape sequences supported by your distribution.

This script will add/remove IP addresses to/from /etc/issue Submit files as needed:

  1. #!/bin/sh
  2. PREFIX="Local IP addresses:"
  3. IPADDRS=$(hostname -I | tr " " "\n" | grep -v "^$" | sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tr "\n" " ")
  4. perl -i -p -0777 -e "s/^$PREFIX[^\n]*\n\n//m; s/$/\n$PREFIX $IPADDRS\n/ if length('$IPADDRS')>6" /etc/issue

If you are using a Debian-based distribution, it is best to put the script in the following location:


  1. /etc/network/if-up.d/update-issue
  2. /etc/network/if-post-down.d/update-issue


In this way, the script will be executed whenever the interface appears or fails. Putting it in /etc/rc.d/rc.local has the disadvantage of only executing it once at startup.



2020年4月9日 星期四

Ubuntu 16.04 install OpenVAS 9

1Install OpenVAS PPA Suite Library

# apt-get install -y software-properties-common
# apt-get install -y python-software-properties
# add-apt-repository ppa: mrazavi / openvas

2. Install openvas software

# apt-get update
# apt-get install -y openvas9

3. Install SQLite3

# apt-get install -y sqlite3

4. Synchronize the latest vulnerability information of openvas

# greenbone-nvt-sync

5. Synchronize SCAP and CERT to the local machine

When synchronizing, one IP can only have one session, if it is interrupted and then reconnected, it may be locked

# greenbone-scapdata-sync 
// Synchronized data is stored in / var / lib / openvas / scap-data
# greenbone-certdata-sync
// Sync data is stored in / var / lib / openvas / cert-data

6. Start the openvas service

# /etc/init.d/redis-server restart
# service openvas-scanner restart
# service openvas-manager restart

7. Rebuild the openvas database

# openvasmd --rebuild --progress

8. Modify the connected web port:

# vi / etc / default / openvas-gsa
PORT_NUMBER = 4000

9. Use PDF Report

# apt-get install -y texlive-latex-extra --no-install-recommends

10. Install the openvas-nasl scanning program

# apt-get install -y libopenvas9-dev

11. Set admin password

# openvasmd --user = admin --new-password = password

If you don't use admin, you can add a user

# openvasmd --create-user = new_user
# gsad --guest-username = new_user --guest-password

12. Login openvas server:

https: //x.x.x.x: 4000

2019年7月17日 星期三

Ubuntu 18.04.1 mysql password settings, and can be set without sudo login

Description:

After installing Ubuntu 18.04.1 , you cannot execute the mysql command as a user. You must use sudo to execute the mysql directive, and any php program may not be able to connect to mysql.


Step1: Login to the mysql interface
example:
Sudo mysql -uroot -p
Enter password: [press Enter directly]

Step2: Modify the account management mode and change password
mysql> Use mysql;
mysql> Update user SET plugin='mysql_native_password' WHERE User='root';
mysql> Update user set authentication_string=password('root new password') where user='root';
mysql> Flush privileges;

Step3: After logging out, you can use the following mysql command without adding sudo

2019年5月29日 星期三

Hide black console window

Step1: First package according to common procedures

Need pyinstaller
example:
First reach the location of this scripts
cd C:\Python27\Scripts
Then enter

pyinstaller -F D:\Wayne\file.py --distpath D:\Wayne
At this time, the folder will be generated on the desktop. build, dist
There is also a protagonist of "Archive.spec"
Open "Profile.spec" with Notepad
One of them is like this

Exe = EXE(pyz,
          A.scripts,
          A.binaries,
          A.zipfiles,
          A.datas,
          [],
          Name='my file',
          Debug=False,
          Bootloader_ignore_signals=False,
          Strip=False,
          Upx=True,
          Runtime_tmpdir=None,
          Console=True )
Change the console=True to console=False

Step2: Repackageirst

Note that this packaged project is a .spec file.
First reach the location of this scripts

cd C:\Python27\Scripts
Then enter
pyinstaller -F D:\Wayne\file.spec --distpath D:\Wayne

You're done, your file will not have a small black frame when you go down.

2019年5月2日 星期四

Ubuntu server 安裝 teamviewer 和使用 teamviewer

Step1: create a folder to save, download the TeamViewer installation package

mkdir ~/downloads/ 
cd ~/downloads/ 
wget https://download.teamviewer.com/download/teamviewer_i386.deb

Step2: TeamViewer installation package

sudo dpkg -i teamviewer_i386.deb
cd /opt/teamviewer/tv_bin
Teamviewer --setup console #Set the startup mode to console startup
Teamviewer --daemon restart #restart teamview service
Sudo teamviewer --passwd 112358 #Set password
Teamviewer --info #teamview # View id

If you get an error, and the content is as follows:
Sudo apt-get install libdbus-1-3:i386 libasound2:i386 libexpat1:i386 libfontconfig1:i386 libfreetype6:i386 libjpeg62:i386 libpng12-0:i386 libsm6:i386 libxdamage1:i386 libxext6:i386 libxfixes3:i

Then execute the command:
sudo apt-get update
sudo apt-get install -f

These two commands are fine.
After this, it will not succeed. When you log in, you will get an error. Failed to start session You can use Ctrl + Alt +F1 to enter the command line and login is OK.

2019年3月19日 星期二

python 測試框架工具

Python的測試框架

Unit frameworks單元測試框架
  • Framework
  • unittest  - python自帶的單元測試庫,開箱即用
  • unittest2  - 加強版的單元測試框架,適用於Python 2.7以及後續版本
  • pytest  - 成熟且功能強大的單元測試框架
  • plugincompat  - pytest的執行及兼容性插件
  • nosetests  - 讓python測試更容易一點
  • slash  - python實現的單元測試框架
  • Extension
  • proboscis  - 仿TestNG擴展了unittest模塊以及Nose的功能
  • grail  -可以讓你一步一步編寫測試用例的庫
  • Testify  - 單元測試框架,提供了加強型夾具,用例切割並行運行,testrunner高亮及詳盡的日誌和報告功能
  • trial  - unittest模塊的擴展,提供了命令行的testrunner工具以及代碼覆蓋率的整合,跟鼻差不多
  • subunit  - 提供了unittest在另一個進程執行用例並彙總測試數據的能力
  • testresources  - 提供了多用例間管理測試數據的機制,兼容unittest
  • testtools  - 為Twisted和Bazaar提供的unittest擴展
  • Sancho  - 運行用例,並為失​​敗的用例提供報告,但僅限於此
  • zope.testing  - testrunner,提供了不錯的debuge能力,並且集成了代碼覆蓋率。可以跟zope項目使用,也可以用在非zope項目上
  • pythoscope  - 自動或半自動為遺留的python系統創建測試用例的工具
  • testlib  - 更強大的unittest,更多的斷言,支持模塊級的設置/拆解,跳過測試等...
  • dutest  - 面向對象的接口,用於從doctests中檢索unittest測試用例。通過允許每個交互式示例的setUp和tearDown來隱藏doctests的初始化。允許控制doctest提供的所有選項。專用類允許跨包層次結構進行選擇性測試發現。
  • green  - 綠色是一個簡潔多彩的testrunner,跟鼻很像
  • ddt  - 讓unittest支持數據驅動
  • pytractor  Selenium python bindings的擴展。目的是讓角項目的測試更簡單
TDD ATDD BDD測試框架

  Assertion
  • pyshould  - 基於pyhamcrest的風格斷言
  • pyhamcrest  - python版的Hamcrest matchers
  • sure  -python實現的測試庫,提供了強大靈活的斷言
  • assertpy  - 巨簡單的python單元測試斷言庫,提供了優雅流利的API。支持Python 2和3。

Discipline
  • mock  - python實現的Mocking和Patching庫
  • Ludibrio  - 用python實現的優雅的測試雙框架(模擬,存根,間諜和假人)。
  • 回复  - mock請求的Python測試工具庫
  • doublex  - 強大的test double frame框架
  • freezegun  - 通過mocking datetime模塊實現時光穿梭
  • httpretty  - HTTP請求的模擬工具
  • httmock  - 要求的模擬工具,支持Python 2.6+和3.2+。
  • 偽裝者  - 測試用的假服務器
  • mock-server  - 簡單的mock sever,支持REST和XML-RPC API,還有基於tornado的管理界面
  • VCR.py  - 自動模擬HTTP交互讓測試更簡單快速

Python的測試數據生成及代碼掃描工具

測試數據操作測試數據的操作和處理
代碼分析代碼掃描及分析

  • pysonar2  - 類型推斷
  • coverage  - 覆蓋率
  • pycallgraph  - 流程可視化
  • Flake8  - 模塊化源代碼檢查器:pep8,pyflakes和co。
  • pylama  - Python和JavaScript的代碼審查工具
  • pylint的  -源代碼分析器
  • hacking  - OpenStack黑客風格檢查(flake8插件)。
  • prospector2  - 代碼分析工具,可以輸出錯誤信息,潛在問題,不規範的代碼以及代碼複雜度

Python的自動化測試工具

Web UI測試自動化Web UI自動化
  • 函式庫
  • selenium webdriver  - 瀏覽器自動化工具
  • splinter  - 簡單的web自動化工具,讓元素定位,表單提交等更加容易
  • mechanize  - 有狀態可編程的瀏覽器
  • 框架和包裝框架和封裝
  • py.saunter  - 有主見的自動化測試框架,使用了selenium RC和webdriver api
  • moz-web-qa  - py.test的插件,為Mozilla的WebQA項目提供了額外功能
  • testutils sst  - 一個Web測試框架,它使用Python生成基於瀏覽器的功能測試。
  • wtframework  - 讓web測試可以配置的框架
  • holmium.core  - Page Object及其他工具庫支持
  • robotframework-selenium2library  - Robot Framework的selenium擴展
  • gocept.selenium  - selenium RC的API,適合編寫基於WSGI,Plone,Zope 2,ZTK或Grok應用的測試用例
  • webium  - 基於python的一個Page Object實現
  • robotframework-anywherelibrary  - Robot Framework的擴展庫,使用selenium2測試web應用,使用appium測試移動應用
  • robotframework-pageobjects  - 一個不錯的Page Object實現,可以脫離機器人框架單獨使用。具體看這裡
  • elementium  - 用jQuery風格的語法糖來實現瀏覽器的自動化測試用例
  • slickqa  - slick -webdriver-python項目是python selenium binding的一個封裝
  • selene  - 簡明的UI測試用例,使用python實現支持Ajax,PageObjects和Widgets
  • hitch  - 編寫基於service的應用的測試用例
  • Needle  - Needle是基於圖片比對的測試工作,它可以對web應用的一部分進行截圖,然後跟預期結果的圖片進行比對
  • PyPOM  - PyPOM是另一個Page Object庫,適用於Selenium和Splinter測試
  • POM  - POM是Page-Object-Model微框架,目的是讓Web UI測試更加簡單,快速和有樂趣
  • websmith  - Web測試的一套 DSL
  • pages  - 輕量的頁面對像庫和組建
  • widgetastic  - RedHat UI小部件組建框架
  • navmazing  - 來自RedHat的基於頁面對象的導航
  • nightwatch  -基於蟒蛇和硒的UI自動化測試框架。靈感來源於nightwatch.js
  • 擴展
  • webdriver_manager  - 主要目的是讓不同版本的瀏覽器driver管理起來更加方便
  • pytest_splinter  - pytest spinter和selenium的集成
  • lettuce_webdriver  - Selenium webdriver的生菜封裝
  • Browsermob Proxy  - python的Browsermob Proxy封裝
  • FireRobot  - 一個Firefox的擴展,讓你可以更高效的編寫基於機器人框架的selenium用例
  • pytractor  - Python的selenium擴展,以便更好的測試angular.js應用
  • Selenium-Requests  - 擴展Selenium WebDriver類,包括了Requests庫的一些功能,可以更方便的處理cookie和請求頭
  • selenium-respectful  - selenium的封裝,可以並行訪問站點
行動裝置 - 自動化測試工具

  • appium  - 開源的自動化測試框架,可以測試native / hybrid / mobile web應用。核心是基於webdriver協議進行了擴展
  • Winium.StoreApps  - 開源的自動化測試用具,用來測試Windows Store應用,實現了Selenium Remote WebDriver
  • robotframework-androidlibrary  - Robot Framework 用來測試android應用的擴展庫
  • robotframework-appiumlibrary  - appium的RobotFramework擴展
  • robotframework-ioslibrary  -Robot的ios測試擴展庫
  • uiautomator  - Android uiautomator的python封裝,支持Android 4.1+
  • ATX  - 智能機自動化測試工具。支持iOS,Android,WebApp和遊戲
Windows UI測試自動化Windows的UI測試工具

  • Winium.Desktop  - 測試Windows應用(主要是基於WinForms和WPF平台)的自動化測試工具。實現了Selenium Remote WebDriver協議
  • PyAutoGUI  - 跨平台的GUI測試工具,支持通過python腳本控制鍵盤和鼠標
  • robotframework-autoitlibrary  - Robot Framework的windows GUI測試擴展
  • autopy  - 簡單跨平台的GUI測試工具集
  • UISoup  - 支持windows和MacOS平台的UI自動化(僅工作在x86平台)
  • pywinauto  - 非常有python面向對像風格的GUI測試庫,現已支持64位機器以及py2和py3
  • SikuliX  - 基於OpenCV的GUI測試框架,使用圖片識別技術,支持python2.7
Unix \ Linux UI測試自動化

  • ldtp  - 跨平台的linux GUI測試項目
  • fMBT  - 支持多平台的python GUI測試庫
  • SikuliX  - 基於OpenCV的GUI測試框架,使用圖片識別技術,支持python2.7
MacOS UI測試自動化MacOS UI自動化測試工具

  • ATOMac  - 通過Apple Accessibility API來測試Mac應用的python庫
  • PyAutoGUI  - 跨平台的GUI測試工具,支持通過python腳本控制鍵盤和鼠標
  • SikuliX  - 基於OpenCV的GUI測試框架,使用圖片識別技術,支持python2.7

Python安全測試API測試及性能測試資源

REST API測試REST API測試
  • Rester - 測試RESTful API的框架
  • pyresttest - REST以及API microbenchmarking工具
  • Rest - Python REST客戶端
虛擬環境虛擬環境
  • virtualenv - 創建隔離的python開發環境的工具
  • virtualenvwrapper - virtualenv的一些擴展
  • tox - 虛擬環境管理,可以在不同的python版本上進行測試和截圖
  • pew - 一些管理虛擬環境的工具
  • Vex - 在命名的虛擬環境運行命令
  • PyRun - 單文件無需按照的python版本
  • pyenv - 簡單的python版本管理
  • Tapper - 全方位的測試基礎設施。
性能和壓力與負載性能測試
  • Multi-Mechanize - 開源的性能測試框架
  • locust - 可擴展的python性能測試工具
  • Yandex.Tank - 性能及基準工具
  • pytest-benchmark - py.test的基準工具
  • Airspeed Velocity - 簡單的Python基準測試工具自帶基於web的報告
  • Grinder - 支持分佈式的負載測試框架。包含一些常規用例,比如HTTP Web服務器,SOAP和REST Web服務,和應用服務器(CORBA,RMI,JMS,EJB),以及定制化的協議。測試腳本使用的Jython和Clojure的實現
  • Tsung - 開源,支持多協議的分佈式性能測試工具。可以測試HTTP,WebDAV,SOAP,PostgreSQL,MySQL,LDAP和Jabber / XMPP服務
  • taurus - 自動化友好的持續測試工具
安全檢查安全掃描
  • sparta - 支持gui的網絡掃描工具
  • OWASP ZAP - 用python實現的OWASP ZAP-features API
  • pythem - pythem是多用途的安全測試工具

 Ubuntu has a mechanism, that is, the installed network card (NIC) will be renamed to another name when the system is booted. Although there...