Fork me on GitHub
image frame

personal notes by mankitty

时间过去,总会丢掉些什么,也总会留下些什么,但留下的必定是最真的东西

Windows7设置进程或者脚本为开机启动

Windows7设置进程或者脚本为开机启动

标签(空格分隔): Windows卡机启动


Windows组策略刷新

  1. 运行/控制台—>regedit打开注册表
  2. CURRENT_USER
    1
    计算机\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\Service
  3. LOCAL_MACHINE
    1
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Service
  4. 示例
    1
    "C:\Program Files\Windows\abc.exe > NUL" /start,如果启动的脚本或者二进制会有输出,可以在启动向后面加 "> NUL"

Windows7开机启动文件

Windows7设置进程或者脚本为开机启动

标签(空格分隔): Windows卡机启动


Windows组策略刷新

  1. 运行/控制台—>regedit打开注册表
  2. CURRENT_USER
    计算机\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\Service
  3. LOCAL_MACHINE
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Service
  4. 示例
    “C:\Program Files\Windows\abc.exe > NUL” /start,如果启动的脚本或者二进制会有输出,可以在启动向后面加 “> NUL”

Windows组策略

Windows组策略

标签(空格分隔): Windows组策略


Windows组策略刷新

  1. 在安装了 NPS 的计算机上,使用任务栏上的图标打开 Windows PowerShell®。
  2. 在 Windows PowerShell 提示符下,键入gpupdate /target:computer /force

Linux通过用户名获取用户的具体信息

Linux通过用户名获取用户的具体信息

标签(空格分隔): Linux


实现代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include <sys/utsname.h>

int main(int argc,char *argv[])
{
struct passwd *pwd = NULL;
/*
*系统文件/etc/passwd包含一个用户帐号数据库。它由行组成,每行对应一个用户,包括:
*用户名、加密口令、用户标识符(UID)、组标识符(GID)、全名、主目录和默认shell。
*编程接口的数据结构:
strcut passwd {
char *pw_name;
char *pw_passwd;
uid_t pw_uid;
gid_t pw_gid;
char *pw_gecos;
char *pw_dir;
char *pw_shell;
}
*/

pwd = getpwnam("cetc");
if (pwd == NULL)
{
printf("user host48 is not exit.\n");
return -1;
}
printf("name=%s, pass=%s, uid=%d, gid=%d, gecos=%s, dir=%s, shell=%s\n",\
pwd->pw_name, pwd->pw_passwd, pwd->pw_uid, pwd->pw_gid, pwd->pw_gecos, pwd->pw_dir, pwd->pw_shell);

return 0;
}

Linux生成core文件、core文件路径设置

设置core文件大小

  1. 设置core文件大小: ulimit -c fileSize core文件超出该大小就不能生成了
  2. 设置core文件无限制: ulimit -c unlimited

设置core文件的名称和文件路径

设置pid作为文件扩展名

修改proc文件修改

echo “1” > /proc/sys/kernel/core_uses_pid

使用sysctl命令修改

sysctl -w kernel.core_uses_pid=1 kernel.core_uses_pid = 1

1
2
1:添加pid作为扩展名,生成的core文件名称为core.pid
0:不添加pid作为扩展名,生成的core文件名称为core

控制core文件保存位置和文件名格式

修改proc文件修改

echo “/corefile/core-%e-%p-%t” > /proc/sys/kernel/core_pattern

使用sysctl命令修改

sysctl -w kernel.core_pattern=/corefile/core.%e.%p.%s.%E

1
2
3
4
5
6
7
8
9
使用上述命令可以将core文件统一生成到/corefile目录下,产生的文件名为core-命令名-pid-时间戳
以下是参数列表:
%p - insert pid into filename 添加pid(进程id)
%u - insert current uid into filename 添加当前uid(用户id)
%g - insert current gid into filename 添加当前gid(用户组id)
%s - insert signal that caused the coredump into the filename 添加导致产生core的信号
%t - insert UNIX time that the coredump occurred into filename 添加core文件生成时的unix时间
%h - insert hostname where the coredump happened into filename 添加主机名
%e - insert coredumping executable name into filename 添加导致产生core的命令名

测试是否能生成core文件

kill -s SIGSEGV $$
查看/corefile目录下是否生成了core文件

组策略--隐藏本地驱动器

隐藏本地驱动器

  1. 运行gpedit.msc
  2. 导航到”用户配置’–”管理模板”–”Windows组件”–”Windows资源管理器’–”隐藏’我的电脑’中的这些指定的驱动器”
  3. 勾选”已启用”并选择要隐藏的驱动器,可以隐藏A、B、C、D或者所有驱动器。

Windows10注册表禁用高级启动选项以及UAC功能

禁用UAC功能

  1. 打开运行输入RegEdit.msc
  2. 在注册表中找到如下的registry key
    1
    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System
  3. 修改EnableLUA值
    修改EnableLUA的注册表项值改为0

    禁用用高级启动

  4. 打开运行输入RegEdit.msc
  5. 计算机本地策略->用户配置->管理模板->所有设置
    1
    找到删除"删除并组织访问关机,"重新启动","睡眠","休眠"命令,并配置为"未配置"

OpenWrt之XHR方法

描述

XHR方法定义在xhr.js文件中,其中定义了get,post,poll,run等方法,其中比较常用的是poll以及get,post方法

方法简介

poll方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
原型:XHR.poll = function(interval, callPath, data, callback)
作用:XHR.poll可以通过callPath定时的从后台获取到数据
参数解释:
interval,定时刷新时间(单位为秒)
callPath,获取数据的路径
data,在获取数据的时候好像没什么用,JS不是太懂,通常都是填null
callback,回调函数,处理获取到的数据
Examples:
[1]. 获取源数据,使用json格式发送出去
function dev_info()

local date = {}
......

luci.http.prepare_content("application/json")
luci.http.write('[')
luci.http.write_json(date)
luci.http.write(']')
end
[2]. 使用XHR.poll获取解析数据
var callPath='<%=luci.dispatcher.build_url("admin", "system", "devinfo",parameter)%>';
XHR.poll(interval,callPath, null,function(x,date){
......
}
);

get方法

XHR.get方法与XHR.poll方法类似,不过,XHR.get方法是一次性调用

nginx+fastcgi搭建web服务器并支持https

描述

CGI全称是“公共网关接口”(Common Gateway Interface),FastCGI与CGI同样都具有语言无关性,可以使用各种语言进行编写。

工作方式

CGI

每当客户请求CGI的时候,WEB服务器就请求操作系统生成一个新的CGI解释器进程(如php-cgi.exe),CGI 的一个进程则处理完一个请求后退出,下一个请求来时再创建新进程。

FastCGI

[1]. Web Server启动时载入FastCGI进程管理器。
[2]. FastCGI进程管理器自身初始化,启动多个CGI解释器进程(可见多个php-cgi)并等待来自Web Server的连接。
[3]. 当客户端请求到达Web Server时,FastCGI进程管理器选择并连接到一个CGI解释器。 Web server将CGI环境变量和标准输入发送到FastCGI子进程。
[4]. FastCGI子进程完成处理后将标准输出和错误信息从同一连接返回Web Server。当FastCGI子进程关闭连接时, 请求便告处理完成。FastCGI子进程接着等待并处理来自FastCGI进程管理器(运行在Web Server中)的下一个连接。

遇到的问题

spawn-fcgi: child exited with: 127

在使用spawn-fcgi绑定的时候,绑定命令如下:spawn-fcgi -a 127.0.0.1 -p 9001 -f /appfs/web/snmpManager.cgi,遇到child exited with: 127问题,试过各种方法,最终看到一个帖子上说,可能CGI程序有问题,我就单独的执行的了一下二进制,结果发现如下问题,./snmpManager.cgi: error while loading shared libraries: libfcgi.so.0: cannot open shared object file: No such file or directory
解决方案:将libfcgi.so.0连接到可以让你所有需要的进程,例如,fcgi以及CGI程序都可以找到的地方

端口问题

原本的端口设置的为87,导致页面显示一直有问题,最后通过开发者工具查看到显示为端口不安全,更改了端口显示才正确

spawn-fcgi绑定命令

spawn-fcgi -a 127.0.0.1 -p 9001 -f /appfs/web/snmpManager.cgi

相关文件下载地址

https://pan.baidu.com/s/1xCCj63WYqcGOHWBZmuHGrw

nginx 编译配置如下

nginx version: nginx/1.8.1
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: –prefix=/usr
–sbin-path=/usr/sbin/nginx
–conf-path=/etc/nginx/nginx.conf
–error-log-path=/var/log/nginx/error.log
–http-log-path=/var/log/nginx/access.log
–http-client-body-temp-path=/etc/nginx/client_body_temp
–http-proxy-temp-path=/etc/nginx/proxy_temp
–http-fastcgi-temp-path=/etc/nginx/fastcgi_temp
–http-uwsgi-temp-path=/etc/nginx/uwscgi_temp
–http-scgi-temp-path=/etc/nginx/scgi_temp
–user=nobody –group=nobody –with-http_sub_module –with-http_stub_status_module
–with-http_gunzip_module –with-http_ssl_module
–add-module=nginx/nginx.auth-1.8.1/src/self/ngx_devel_kit
–add-module=nginx/nginx.auth-1.8.1/src/self/set-misc-nginx-module
–with-pcre=nginx.auth/pcre-8.36

nginx 配置文件如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
user root root;
worker_processes auto;

events {
worker_connections 1024;
}

http {
include mime.types;
keepalive_timeout 65;
sendfile on;
gzip on;

server {
listen 24796;
listen 443 default ssl;
server_name localhost;

ssl on;
ssl_certificate /appfs/etc/nginx.auth/ssl/server.crt;
ssl_certificate_key /appfs/etc/nginx.auth/ssl/server.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

keepalive_timeout 65;

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;

# CGI以及html所在的目录
root /appfs/web;

location / {
index index.php index.html index.htm;
}

location ~ \.cgi$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9001;
#fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
#fastcgi_pass unix:/tmp/php-cgi.sock;
#try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.cgi)(/.+)$;
fastcgi_index snmpManager.cgi;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
}

HTTPS加密连接

OpenSSL 1.0.0生成p12、jks、crt等格式证书的命令个过程
参考文章 OpenSSL 1.0.0生成p12、jks、crt等格式证书的命令个过程(转)

创建根证私钥

openssl genrsa -out root-key.key 1024

创建根证书请求文件

openssl req -new -out root-req.csr -key root-key.key -keyform PEM

自签根证书

openssl x509 -req -in root-req.csr -out root-cert.cer -signkey root-key.key -CAcreateserial -days 3650

导出p12格式根证书

openssl pkcs12 -export -clcerts -in root-cert.cer -inkey root-key.key -out root.p12

生成root.jks文件

keytool -import -v -trustcacerts -storepass 123456 -alias root -file root-cert.cer -keystore
root.jks

生成客户端文件

生成客户端key

openssl genrsa -out client-key.key 1024

生成客户端请求文件

openssl req -new -out client-req.csr -key client-key.key

生成客户端证书(root证书,rootkey,客户端key,客户端请求文件这4个生成客户端证书)

openssl x509 -req -in client-req.csr -out client-cert.cer -signkey client-key.key -CA root-cert.cer
-CAkey root-key.key -CAcreateserial -days 3650

生成客户端p12格式根证书

openssl pkcs12 -export -clcerts -in client-cert.cer -inkey client-key.key -out client.p12

客户端jks:

keytool -import -v -trustcacerts -storepass 123456 -alias client -file client-cert.cer -keystore
client.jks

生成服务端文件

生成服务端key

openssl genrsa -out server-key.key 1024

生成服务端请求文件

openssl req -new -out server-req.csr -key server-key.key

生成服务端证书(root证书,rootkey,客户端key,客户端请求文件这4个生成客户端证书)

openssl x509 -req -in server-req.csr -out server-cert.cer -signkey server-key.key -CA root-cert.cer
-CAkey root-key.key -CAcreateserial -days 3650

生成服务端p12格式根证书

openssl pkcs12 -export -clcerts -in server-cert.cer -inkey server-key.key -out server.p12

服务端JKS

keytool -import -v -trustcacerts -storepass 123456 -alias server -file server-cert.cer -keystore
server.jks

无密码key命令

openssl rsa -in client-key.key -out client-key.key.unsecure

  • © 2015-2020 Mankitty
  • Powered by Hexo Theme Ayer
  • PV: UV:

请我喝杯咖啡吧~

支付宝
微信