我爱编程网小编给大家带来了exec执行某命令在命令行下没有问题,但是在php中就出错(Web小白的CTF自学笔记(5)——PHP基础)相关文章,一起来看一下吧。
本文目录一览:

exec执行某命令在命令行下没有问题,但是在php中就出错
什么系统?win还是linux?
一般是权限的问题,win下可以使用这个函数:
function exec_wincmd($cmd)
{
$WshShell = new COM("WScript.Shell");
$cwd = getcwd();
if (strpos($cwd,' '))
{ if ($pos = strpos($cmd, ' '))
{ $cmd = substr($cmd, 0, $pos) . '" ' . substr($cmd, $pos);
}
else
{ $cmd .= '"';
}
$cwd = '"' . $cwd;
}
$oExec = $WshShell->Run("cmd /C \" $cmd\"", 0,true);
return $oExec == 0 ? true : false;
}

Web小白的CTF自学笔记(5)——PHP基础
PHP Tutorial (w3schools.com)
在自学PHP基础的过程中,需要掌握大量漏洞函数。若不想记忆,可以参考我编写的插件来辅助学习。
@符号用于禁止错误输出的回显。
$符号是取址符,用于获取名为a的变量的值。
使用反引号`包裹的字符串会被当作系统命令执行,但无回显,需要通过echo来显示结果。
字符串有四种表示方法:单引号、双引号、花括号和以反引号开头。
变量名可以是$a、${'a'}或${a}(带警告)。
函数名可以是字符串变量或字符串(带"或')。
在PHP 7和8中,函数名可以用不带'、不带"的字符串通过()表示。
在PHP 5和7中,索引字符串可不带'或"。
在PHP 5和PHP 7中,{}可替代[]作为索引符。
关于弱比较漏洞函数intval,它将字符串解析为整型,将小数去尾,但传入非空数组返回1,空数组返回0。
PHP通常使用IEEE 754双精度格式,当小数小于10^-16后,PHP对于小数就大小不分了。
preg_match函数用于正则匹配字符串,传入数组返回false。
PHP为了防止正则表达式的拒绝服务攻击(reDOS),给pcre设定了一个回溯次数上限,可以通过var_dump(ini_get('pcre.backtrack_limit'));查看当前环境下的上限。
eregi函数在PHP 5中不区分大小写地搜索字符串,可被00截断,在PHP 7中已修复。
in_array函数用于判断数组中是否存在指定的值。
strcmp函数用于比较两个字符串,如果第一个字符串小于第二个字符串返回-1,如果大于返回1,如果相等返回0。
is_numeric函数用于判断变量是否是数字或数字字符串。
basenamemd5函数用于获取字符串的MD5值。
0e漏洞:'0e...'字符串在!= ==比较时会当作0。
MD5值强相等(非字符串):使用FastColl实现字符串强碰撞。
sha1函数在传入数组或无参数时返回NULL。
伪随机数可以使用php_mt_seed - PHP mt_rand() seed cracker破解。
include函数允许文件名结尾有空格。
include_once函数与include的区别在于,当用include_once重复包含时,需要在路径前加上。
import_request_variables函数指定导入GET请求中的变量。
register_globals变量当php.ini中register_globals=ON时,提交test.php?auth=1,$auth变量将自动得到赋值。
parse_str函数和mb_parse_str()解析URL中的querystring,将变量保存到后端环境中。
get_defined_vars()函数返回数组,包含所有变量名和值。
get_defined_functions()函数在PHP7和8中可用。
ReflectionClass类用于实例化Obj类。
$_SERVER[QUERY_STRING]和$_SERVER[REQUEST_URI]中的GET参数不会被URL解码。
$_REQUEST函数会同时获取GET和POST参数。
文件读取函数echo new FilesystemIterator(getcwd());查看当前目录。
路径本地文件路径子文件夹/../本地文件=本地文件,某些系统中,存在/../本地文件=本地文件。
/proc/self/cwd指当前进程的目录。
网络URL路径
可访问到
。
easyphpthumbnail,phpthumb哪 个更好
我爱编程网(https://www.52biancheng.com)小编还为大家带来easyphpthumbnail,phpthumb哪 个更好的相关内容。
EasyPHPThumbnail类可以处理图像和PHP生成缩略图支持GIF、JPG和PNG。这个类是免费的,基于100%的PHP,可用于PHP4(4.3.11以上)和PHP5,易于使用,并提供了超过60的功能操作:
提供的功能包括:调整大小,裁剪,旋转,翻转,另存为,阴影,水印,文字,边框,锐化,模糊,水波纹,反射镜,透视,动画,置换贴图和更多!
使用简介
1、基本使用
<?php
include_once('inc/easyphpthumbnail.class.php');
$thumb = new easyphpthumbnail;
$thumb -> Createthumb('gfx/image.jpg');
?>
2、动态显示指定大小图片
<?php
include_once('inc/easyphpthumbnail.class.php');
// Your full path to the images
$dir = str_replace(chr(92),chr(47),getcwd()) . '/gfx/';
// Create the thumbnail
$thumb = new easyphpthumbnail;
$thumb -> Thumbsize = 300;
$thumb -> Createthumb($dir . 'img.jpg');
?>
3、生成静态多张本地图片
<?php
include_once('inc/easyphpthumbnail.class.php');
// Your full path to the images
$dir = str_replace(chr(92),chr(47),getcwd()) . '/gfx/';
$dir_thumbs = str_replace(chr(92),chr(47),getcwd()) . '/thumbs/';
if(!is_dir($dir_thumbs)) mkdir($dir_thumbs,0777);
// Create the thumbnail
$thumb = new easyphpthumbnail;
$thumb -> Thumbsize = 600;
$thumb -> Copyrighttext = 'SCUTEPHP.COM';
$thumb -> Copyrightposition = '50% 90%';
$thumb -> Copyrightfonttype = $dir . 'handwriting.ttf';
$thumb -> Copyrightfontsize = 30;
$thumb -> Copyrighttextcolor = '#FFFFFF';
$thumb -> Chmodlevel = '0755';
$thumb -> Thumblocation = $dir_thumbs;
$thumb -> Thumbsaveas = 'jpg';
$thumb -> Thumbprefix = '120px_thumb_';
$thumb -> Createthumb(array($dir . '69.jpg', $dir . '70.jpg'), 'file');
?>
4、图片大小百分比调整及图片旋转
<?php
include_once('inc/easyphpthumbnail.class.php');
$thumb = new easyphpthumbnail;
$thumb -> Thumbsize = 50;
$thumb -> Rotate = 90;//指定度数旋转
//$thumb -> Fliphorizontal = true; //水平轴旋转
//$thumb -> Flipvertical = true; //垂直轴旋转
$thumb -> Percentage = true;
$thumb -> Createthumb('gfx/image.jpg');
?>
Thumbsize默认是px像素单位,然而要用百分比的话可以设置Percentage属性为ture,Rotate属性设置顺时针旋转度数。
5、给缩略图增加背景阴影
<?php
include_once('inc/easyphpthumbnail.class.php');
$thumb = new easyphpthumbnail;
$thumb -> Backgroundcolor = '#D0DEEE';
$thumb -> Shadow = true;
$thumb -> Createthumb('gfx/image.jpg');
?>
6、给缩略图增加圆角效果
<?php
include_once('inc/easyphpthumbnail.class.php');
$thumb = new easyphpthumbnail;
$thumb -> Backgroundcolor = '#D0DEEE';
$thumb -> Clipcorner = array(2,15,0,0,1,1,0);
$thumb -> Createthumb('gfx/image.jpg');
?>
Clipcorner属性的7个参数含义
[0]: 0=关闭 1=直角 2=圆角
[1]: 裁剪比例
[2]: 随机 - 0=关闭 1=开启
[3]: 左上 - 0=关闭 1=开启
[4]: 左下 - 0=关闭 1=开启
[5]: 右上 - 0=关闭 1=开启
[6]: 右下 - 0=关闭 1=开启
7、给缩略图增加透明效果
<?php
include_once('inc/easyphpthumbnail.class.php');
$thumb = new easyphpthumbnail;
$thumb -> Backgroundcolor = '#0000FF';
$thumb -> Clipcorner = array(2,15,0,1,1,1,1);
$thumb -> Maketransparent = array(1,1,'#0000FF',30);
$thumb -> Createthumb('gfx/image.jpg');
?>
8、给缩略图增加框架效果
<?php
include_once('inc/easyphpthumbnail.class.php');
$thumb = new easyphpthumbnail;
$thumb -> Framewidth = 10;
$thumb -> Framecolor = '#FFFFFF';
$thumb -> Backgroundcolor = '#D0DEEE';
$thumb -> Shadow = true;
$thumb -> Createthumb('gfx/image.jpg');
?>
9、给缩略图增加经典相框效果
<?php
include_once('inc/easyphpthumbnail.class.php');
$thumb = new easyphpthumbnail;
$thumb -> Framewidth = 10;
$thumb -> Framecolor = '#FFFFFF';
$thumb -> Backgroundcolor = '#D0DEEE';
$thumb -> Shadow = true;
$thumb -> Binder = true;
$thumb -> Binderspacing = 8;
$thumb -> Clipcorner = array(2,15,0,1,1,1,0);
$thumb -> Createthumb('gfx/image.jpg');
?>
10、给缩略图增加水印效果
<?php
include_once('inc/easyphpthumbnail.class.php');
$thumb = new easyphpthumbnail;
$thumb -> Thumbsize = 300;
$thumb -> Framewidth = 10;
$thumb -> Framecolor = '#00000';
$thumb -> Backgroundcolor = '#000000';
$thumb -> Clipcorner = array(2,15,0,1,1,1,1);
$thumb -> Watermarkpng = 'watermark.png';
$thumb -> Watermarkposition = '50% 50%';
$thumb -> Watermarktransparency = 70;
$thumb -> Createthumb('gfx/image.jpg');
?>
11、给缩略图增加短文本及相框
<?php
include_once('inc/easyphpthumbnail.class.php');
$thumb = new easyphpthumbnail;
$thumb -> Thumbsize = 300;
$thumb -> Framewidth = 10;
$thumb -> Framecolor = '#00000';
$thumb -> Borderpng = 'border.png';
$thumb -> Copyrighttext = 'MYWEBMYMAIL.COM';
$thumb -> Copyrightposition = '50% 80%';
$thumb -> Copyrightfonttype = 'handwriting.ttf';
$thumb -> Copyrightfontsize = 30;
$thumb -> Copyrighttextcolor = '#FFFFFF';
$thumb -> Createthumb('gfx/image.jpg');
?>
12、缩略图按指定形状裁剪
<?php
include_once('inc/easyphpthumbnail.class.php');
$thumb = new easyphpthumbnail;
$thumb -> Thumbsize = 300;
$thumb -> Borderpng = 'cloud.png';
$thumb -> Createthumb('gfx/image.jpg');
?>
13、指定区域裁剪图片
<?php
include_once('inc/easyphpthumbnail.class.php');
$thumb = new easyphpthumbnail;
$thumb -> Thumbsize = 300;
$thumb -> Cropimage = array(2,0,20,20,35,35);
$thumb -> Createthumb('gfx/image.jpg');
?>
Cropimage属性六个参数说明
[0]: 0=disable 1=enable free crop 2=enable center crop
[1]: 0=percentage 1=pixels
[2]: Crop left
[3]: Crop right
[4]: Crop top
[5]: Crop bottom
14、裁剪出旧照片效果
<?php
include_once('inc/easyphpthumbnail.class.php');
$thumb = new easyphpthumbnail;
$thumb -> Thumbsize = 300;
$thumb -> Shadow = true;
$thumb -> Backgroundcolor = '#D0DEEE';
$thumb -> Cropimage = array(2,0,20,20,35,35);
$thumb -> Ageimage = array(1,10,80);
$thumb -> Createthumb('gfx/image.jpg');
?>
15、属性或方法详解
A
$thumb -> Addtext = array()// 对原始图像添加文字
数组有六个参数
[0]: 0=disable 1=enable
[1]: The text to add
[2]: The position of the text '50% 50%' is the center
[3]: Path to the TTF font (standard systemfont will be used)
[4]: The fontsize to use
[5]: The copyright text color in web format '#000000'
$thumb -> Ageimage = (array) // 应用灰度 array(1,0,0) 或者旧照片效果 array(1,10,80)
数组有六个参数
[0]: Boolean 0=disable 1=enable
[1]: Add noise 0-100, 0=disable
[2]: Sephia depth 0-100, 0=disable (greyscale)
$thumb -> Applyfilter = (boolean)// 应用用户自定义3x3过滤器
B
$thumb -> Backgroundcolor = (string)// Web格式的背景 '#FFFFFF'
$thumb -> Binder = (boolean) // 在缩略图左边画一粘合剂
$thumb -> Binderspacing = (int) // 以像素为单位的空间
$thumb -> Blur = (boolean) // 模糊过滤器
$thumb -> Borderpng = (string) // 边框PNG图片路径
$thumb -> Brightness = (array) // 改变图片亮度
数组有两个参数
[0]: Boolean 0=disable 1=enable
[1]: Brightness -100 to 100
C
$thumb -> Chmodlevel = (string) // 设置保存图片的权限 '0755'
$thumb -> Clipcorner = (array) // 设置圆角 array(2,15,0,1,1,1,0)
数组有七个参数
[0]: 0=disable 1=straight 2=rounded
[1]: Percentage of clipping
[2]: Clip randomly Boolean 0=disable 1=enable
[3]: Clip top left Boolean 0=disable 1=enable
[4]: Clip bottom left Boolean 0=disable 1=enable
[5]: Clip top right Boolean 0=disable 1=enable
[6]: Clip bottom right Boolean 0=disable 1=enable
$thumb -> Colorreplace = (array)// 颜色替换 array(1,'#FFFFFF','#FF6600',60)
数组有四个参数
[0]: Boolean 0=disable 1=enable
[1]: Color to replace in web format: '#00FF00'
[2]: Replacement color in web format: '#FF0000'
[3]: RGB tolerance 0 - 100
$thumb -> Colorize = (array) // 合并图像中的颜色 array(1,0,0,125,0)
数组有五个参数
[0]: Boolean 0=disable 1=enable
[1]: Red component 0 - 255
[2]: Green component 0 - 255
[3]: Blue component 0 - 255
[4]: Opacity level 0 - 127
$thumb -> Contrast = (array)// 改变图像的对比度 array(1,30)
数组有2个参数
[0]: Boolean 0=disable 1=enable
[1]: Contrast -100 to 100
$thumb -> Copyrighttext = (string) // 增加版权文本
$thumb -> Copyrightposition = (string) // 版权文本位置 '50% 50%' is the center
$thumb -> Copyrightfonttype = (string)// TTF文字字体路径 (standard systemfont will be used)
$thumb -> Copyrightfontsize = (int)// 字体大小
$thumb -> Copyrighttextcolor = (string) // 文字Web格式颜色值 '#000000'
$thumb -> Createthumb('imagepath'[,'output']) // 创建或者输出缩略图
函数有两个参数
[string/array]: 原图片完整路径字符串或数组
[string]: Output to the 'screen' (standard) or 'file' (option)
$thumb -> Createbase64('imagepath')// 以base64数据输出图片
函数有一个参数
[string]: Filename for image to convert
$thumb -> Createcanvas(i,i,i,s,b)// 创建一个画布图像 - use with Createthumb()
函数有五个参数
[int]: Canvas width in pixels
[int]: Canvas height in pixels
[int]: Imagetype PHP: IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_JPEG
[string]: Fill color
[boolean]: Transparent (boolean)
$thumb -> Create_apng(array, string, int)// 创建APNG缩略图
函数有三个参数
[array]: Array with filenames of PNG images (frames)
[string]: Filename for APNG: 'animation.png'
[int]: Delay between frames in milliseconds
$thumb -> Cropimage = (array)// 裁剪 array(0,0,20,20,20,20)
数组有六个参数
[0]: 0=disable 1=free crop 2=center crop 3=square crop
[1]: 0=percentage 1=pixels
[2]: Crop left
[3]: Crop right
[4]: Crop top
[5]: Crop bottom
$thumb -> Croprotate = (boolean)// 裁剪图片到同样大小的画布并旋转
D
$thumb -> Displacementmap = (array) // 变形
数组有7个参数: array(1,'gfx/displacementmap.jpg',0,0,0,50,50)
[0]: 0=disable 1=enable
[1]: Path to displacement image (grey #808080 is neutral)
[2]: 0=resize the map to fit the image 1=keep original map size
[3]: X coordinate for map position in px
[4]: Y coordinate for map position in px
[5]: X displacement scale in px
[6]: Y displacement scale in px
$thumb -> Displacementmapthumb = (array) // 缩略图变形
数组有七个参数: array(1,'gfx/displacementmap.jpg',0,0,0,50,50)
[0]: 0=disable 1=enable
[1]: Path to displacement image (grey #808080 is neutral)
[2]: 0=resize the map to fit the image 1=keep original map size
[3]: X coordinate for map position in px
[4]: Y coordinate for map position in px
[5]: X displacement scale in px
[6]: Y displacement scale in px
$thumb -> Divisor = (int)// The divisor for the 3x3 filter
E
$thumb -> Edge = (boolean)// 边缘过滤器
$thumb -> Emboss = (boolean) // 浮雕过滤器
F
$thumb -> Fliphorizontal = (boolean)// 在水平轴翻转图像
$thumb -> Flipvertical = (boolean) // 在垂直轴翻转图像
$thumb -> Filter = (array)// 3x3矩阵 array(-1,-1,-1,-1,8,-1,-1,-1,-1)
数组有九个参数
[0]: a1,1
[1]: a1,2
[2]: a1,3
[3]: a2,1
[4]: a2,2
[5]: a2,3
[6]: a3,1
[7]: a3,2
[8]: a3,3
$thumb -> Framewidth = (int)// 添加缩略图框架(像素)
$thumb -> Framecolor = (string) // 框架颜色 '#FFFFFF'
我爱编程网以上就是我爱编程网小编给大家带来的exec执行某命令在命令行下没有问题,但是在php中就出错(Web小白的CTF自学笔记(5)——PHP基础),希望能对大家有所帮助。更多相关文章关注我爱编程网:
www.52biancheng.com免责声明:文章内容来自网络,如有侵权请及时联系删除。