Browse Source

I cannot believe that it took this long to write a test for this.

John ShaggyTwoDope Jenkins 4 years ago
parent
commit
0f8f21684d
3 changed files with 55 additions and 2 deletions
  1. 9
    0
      archofflinewikisearch.sh
  2. 2
    2
      convertvideosavitomp4
  3. 44
    0
      src/ghost.c

+ 9
- 0
archofflinewikisearch.sh View File

@@ -0,0 +1,9 @@
1
+#!/usr/bin/env bash
2
+# AUTHOR:   shaggy
3
+# FILE:     archofflinewikisearch.sh
4
+# ROLE:     TODO (some explanation)
5
+# CREATED:  2015-02-12 15:54:16
6
+# MODIFIED: 2015-02-12 15:55:48
7
+
8
+cd /usr/share/doc/arch-wiki/html/
9
+grep -i "$1" index.html | sed 's/.*HREF=.\(.*\.html\).*/\1/g' | xargs opera -newpage

+ 2
- 2
convertvideosavitomp4 View File

@@ -1,8 +1,8 @@
1 1
 #!/bin/sh
2 2
 
3
-mkdir convert
3
+#mkdir convert
4 4
 
5
-for f in *.avi; do ffmpeg -i "$f" convert/"${f%.avi}.mp4"; done
5
+for f in *.avi; do ffmpeg -i "$f" "${f%.avi}.mp4"; done
6 6
 
7 7
 
8 8
 #find -name '*.avi' -exec ffmpeg -i {} {}.mp4 \;

+ 44
- 0
src/ghost.c View File

@@ -0,0 +1,44 @@
1
+/**
2
+ *
3
+ * test for
4
+ * https://www.qualys.com/research/security-advisories/GHOST-CVE-2015-0235.txt
5
+**/
6
+
7
+#include <netdb.h>
8
+#include <stdio.h>
9
+#include <stdlib.h>
10
+#include <string.h>
11
+#include <errno.h>
12
+
13
+#define CANARY "in_the_coal_mine"
14
+
15
+struct {
16
+  char buffer[1024];
17
+  char canary[sizeof(CANARY)];
18
+} temp = { "buffer", CANARY };
19
+
20
+int main(void) {
21
+  struct hostent resbuf;
22
+  struct hostent *result;
23
+  int herrno;
24
+  int retval;
25
+
26
+  /*** strlen (name) = size_needed - sizeof (*host_addr) - sizeof (*h_addr_ptrs) - 1; ***/
27
+  size_t len = sizeof(temp.buffer) - 16*sizeof(unsigned char) - 2*sizeof(char *) - 1;
28
+  char name[sizeof(temp.buffer)];
29
+  memset(name, '0', len);
30
+  name[len] = '\0';
31
+
32
+  retval = gethostbyname_r(name, &resbuf, temp.buffer, sizeof(temp.buffer), &result, &herrno);
33
+
34
+  if (strcmp(temp.canary, CANARY) != 0) {
35
+    puts("vulnerable");
36
+    exit(EXIT_SUCCESS);
37
+  }
38
+  if (retval == ERANGE) {
39
+    puts("not vulnerable");
40
+    exit(EXIT_SUCCESS);
41
+  }
42
+  puts("should not happen");
43
+  exit(EXIT_FAILURE);
44
+}

Loading…
Cancel
Save