关于环境配置的坑总是层出不穷的,本文意在整理最佳解决方法,避免再次踩坑。为防止网上原文遗失记录主要步骤。谷歌是最好的帮手。
置顶:
Ubuntu:Could not get lock /var/lib/dpkg/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock
阿里云Docker镜像加速
最近在阿里云ECS上docker pull
很慢,换中科大源也无济于事。
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://9vk4rkxv.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
Docker版本需要大于1.10.0。再吐槽一下ECS上这些包管理服务都不给预先优化的,git clone`
docker pull`这种常见操作都体验极差。
npm install 报错 node-sass问题
Module build failed: Error: Missing binding F:\GP\vue-admin-flask-example\node_modules\node-sass\vendor\win32-x64-57\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 8.x
Found bindings for the following environments:
- Windows 64-bit with Node.js 8.x
This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.
node-sass
这个包比较特殊,就算使用了npm install --registry=https://registry.npm.taobao.org
安装也会出现问题。涉及到这个包的项目,一律在项目根目录下touch .npmrc
,输入两行配置:
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
registry=https://registry.npm.taobao.org
保存后再npm install
或npm rebuild node-sass
即可。
RSA解题环境配置
安装pycrypto报错unable to find vcvarsall.bat
在\Lib\distutils_msvccompiler.py
中找到_find_vcvarsall(plat_spec)
函数的version版本,安装对应版本Visual Studio,勾选VC++2015、Python Tools和Web Deveolper Tools。
添加用户环境变量:
变量名:VCINSTALLDIR
变量值:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
set CL=/FI"%VCINSTALLDIR%\\INCLUDE\\stdint.h" %CL%
然后就可以直接pip install了。
gmpy2安装
从置顶的第二个链接下载对应Python版本(即CPxx)的包:
Linux下参考 https://www.cnblogs.com/pcat/p/5746821.html
winrandom
Vmware配置虚拟机静态IP(Ubuntu为例)
编辑-虚拟网络编辑器-VMnet8-取消勾选DHCP,此处子网IP末字节必须填0,否则会提示子网掩码不匹配。
虚拟机设置-网络适配器-自定义中选择对应虚拟网卡
GUI配置:Ubuntu 连接方式从DHCP改为手动,在这里编辑具体的主机地址。网关可以在步骤1中查看。
终端配置
sudo vi /etc/network/interfaces
auto lo
iface lo inet loopback
auto ens0//要注意默认网卡名在Ubuntu15后改为了ens33
iface ens0 inet static
address 192.168.2.66
netmask 255.255.255.0
gateway 192.168.2.2
两种方式等效,从GUI添加后此文件也会被修改。
注意别忘了配置DNS:
sudo vi /etc/resolv.conf
nameserver 223.5.5.5 //阿里dns
ip link set eth0 up
LAMP环境配置(以Ubuntu16.04 LTS为例)
apt-get update
更新源
/etc/hostname
、/etc/hosts
美化主机名
127.0.0.1 localhost
127.0.0.1 Fazx
sudo apt-get install apache2
service apache2 status
service apache2 restart
sudo apt-get install php7.0
sudo apt-get install libapache2-mod-php7.0 #否则不能解析
sudo apt-get install mysql-server
sudo apt-get install phpmyadmin php-mbstring php-gettext
,选择apache2。
安装完成之后使用如下两个命令修改支持模块:
sudo phpenmod mcrypt
sudo phpenmod mbstring
sudo systemctl restart apache2
angr安装(符号执行)
安装依赖:
sudo apt-get install python-dev libffi-dev build-essential virtualenvwrapper
如果你正在尝试angr管理,你会需要安装:
sudo apt-get install libqt4-dev graphviz-dev
pip install angr
git bash 上传新项目
#新建空文件夹
git init
#从github创建repo
git remote add origin git@github.com:Fazx/SdusterBlog.git
git add .
git commit -m "xxx"
由于远程库是空的,第一次推送master分支时,加上了-u参数,Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就可以简化命令。
git push -u origin master
若出现error: failed to push some refs to 'git@github.com:....."
报错,
则应现将本地和远程的文件合并后再上传:git pull origin master
git 撤销修改/版本回退
撤销修改
未添加到暂存区:
git checkout -- file
丢弃工作区的修改
经git add
添加到暂存区后:
git reset HEAD <file>
版本回退
已经git commit
提交到版本库:
git log
查看commit id
git reset --hard commit_id #前几位即可
VNC访问Ubuntu 16.04
从桌面共享设置允许进行远程控制
安装vncserver的基础服务:sudo apt-get install xrdp vnc4server xbase-clients
安装dconf-editor工具以取消加密:
sudo apt-get install dconf-editor
使用VNC viewer或直接mstsc连接:
Ubuntu更换PHP启用版本
#查看已经安装的 PHP 包
dpkg -l | grep php| awk '{print $2}' |tr "\n" " "
#添加 PHP PPA
sudo add-apt-repository ppa:ondrej/php
#安装 PHP5.6
sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml libapache2-mod-php5.6
#禁用 Apache 中的 PHP7
sudo a2dismod php7
#启用 PHP5.6
sudo a2enmod php5.6
#重启 Apache
sudo systemctl restart apache2.service
#切换 CLI
sudo update-alternatives --set php /usr/bin/php5.6
burp返回包乱码
Docker中科大源
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce
Docker compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# 最新版本从https://github.com/docker/compose/releases
sudo chmod +x /usr/local/bin/docker-compose
vim
sudo apt-get remove vim-common
sudo apt-get install vim
cmder设置代理
cmd在默认情况下,即使开启全局代理也不会走代理,可以如下设置:
# 在一个cmder session中有效
Set http_proxy=http://[proxy]:[port]
Set https_proxy=http://[proxy]:[port]
# 取消
set http_proxy=
set https_proxy=
# Ubuntu下set改为export
看图:
也不知道为啥挂上代理给我定宿迁去了。。
set http_proxy=http://127.0.0.1:1080 && set https_proxy=http://127.0.0.1:1080
git clone嗖嗖的
sublime编译python乱码问题
写网页爬虫时经常遇到错误提示UnicodeDecodeError: 'gbk' codec can't decode bytes
在Python3.sublime-build
文件里添加"env":{"PYTHONIOENCODING":"utf8"}
Apache2下多IP对应多站点(虚拟主机)
基本没找到什么靠谱的教程,老旧的文章还在让配置/etc/httpd/conf/httpd.conf
,配置文件的目录都已经换了。
主配置文件/etc/apache2/apache2.conf
的最后两行描述了有关虚拟站点的配置:
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
以下是配置流程:
$sudo ifconfig eth0:0 10.1.1.120 up
$sudo ifconfig eth0:1 10.1.1.121 up //注意,此时的设备名为eth0:1
在/etc/apache2/sites-available
下建立a.conf
和b.conf
,从000-default.conf
修改配置文件如下图:
注意是加一行ServerName
,/var/www/
下是自己新建的网站目录。接下来在/etc/apache2/sites-enabled
下添加符号链接(又叫软链接,类似win下的快捷方式):
sudo ln -s /etc/apache2/sites-available/www-linuxidc-com.conf /etc/apache2/sites-enabled/www-linuxidc-com.conf
sudo ln -s /etc/apache2/sites-available/www-wordpress-com.conf /etc/apache2/sites-enabled/www-wordpress-com.conf
如果是从域名访问,记得还要改hosts的映射。
SSH代理服务
ssh -N -f -D 0.0.0.0:2080 192.168.211.168 -p22 -b 0.0.0.0
migrate 进程注入
接收到 meterpreter 之后就应该将自己的进程迁移到一个隐蔽的进程中去,防止被查杀,直接在meterpreter中使用migrate PID;
meterpreter > getpid
Current pid: 1784
meterpreter > ps
Process List
============
PID PPID Name Arch Session User Path
--- ---- ---- ---- ------- ---- ----
1784 3016 shell.exe x86 2 Go0s-PC\Go0s C:\Users\Go0s\Desktop\shell.exe
3016 1124 explorer.exe x64 2 Go0s-PC\Go0s C:\Windows\explorer.exe
meterpreter > migrate 3016
[*] Migrating from 1784 to 3016...
[*] Migration completed successfully.
meterpreter > getpid
Current pid: 3016
Pentestbox update all后msf报错
pentestbox在通过update all
更新后,使用msfconsole
会报错:
Bundler could not find compatible versions for gem "aws-sdk-iam":
In Gemfile:
metasploit-framework x86-mingw32 was resolved to 5.0.43, which depends on
aws-sdk-iam x86-mingw32
Could not find gem 'aws-sdk-iam', which is required by gem 'metasploit-framework', in any of the sources.
#cd到msf的目录下
git reset --hard
git pull
#再次安装依赖
bundle install
gem uninstall bcrypt
gem uninstall bcrypt-ruby
gem install bcrypt --platform=ruby