1
0
mirror of https://github.com/nmap/nmap.git synced 2026-02-10 23:46:34 +00:00

Copy nping, nsock, nbase, zenmap, ncat from their homes in /.

If you have trouble updating after this revision you need to follow
these instructions. You have probably just seen an error like this:

svn: URL 'svn://svn.insecure.org/nping' of existing directory 'nping'
does not match expected URL 'svn://svn.insecure.org/nmap/nping'

This is caused by the replacement of SVN externals.

Here's what you need to do. First, save any local changes you might have
in the nping, nsock, nbase, ncat, and zenmap directories. (For example
by running "cd nping; svn diff > ../nping.diff".) If you don't have any
local changes you can skip this step.

Then run these commands:

rm -rf nping/ nsock/ nbase/ ncat/ zenmap/
svn update
svn cleanup

If all else fails, you can just delete your whole working directory and
check out anew:

svn co --username guest --password "" svn://svn.insecure.org/nmap

There may be further discussion in the mailing list thread at
http://seclists.org/nmap-dev/2011/q4/303.
This commit is contained in:
david
2011-11-16 21:49:44 +00:00
parent 4dabecf3b8
commit ed2ba4e168
619 changed files with 351133 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
Every script under this directory is supposed to be executed from the
top of the source tree. Don't get into this directory, nor any other
under this one to execute any of the scripts, or they're not going to
work as expected.
This is a description of the scripts in this directory and its
subdirectories.
macosx:
Files and scripts used to build Mac OS X packages. See macosx/README for a
description of the files in this directory.
utils/version_update.py:
Updates the Zenmap version number everywhere it needs to be.
windows/copy_and_compile.bat:
Builds a Windows executable using py2exe.
windows/nmap-eye.ico:
An icon used on Windows.

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>org.insecure.Zenmap</string>
<key>CFBundleName</key>
<string>Zenmap</string>
<key>NSHumanReadableCopyright</key>
<string>© Insecure.Com LLC</string>
</dict>
</plist>

View File

@@ -0,0 +1,219 @@
diff --unidirectional-new-file -ru -x 'PortIndex*' ports.orig/devel/atk/Portfile ports/devel/atk/Portfile
--- ports.orig/devel/atk/Portfile 2011-07-12 06:30:20.000000000 -0700
+++ ports/devel/atk/Portfile 2011-10-13 18:38:07.000000000 -0700
@@ -31,12 +31,10 @@
port:gtk-doc
depends_lib path:lib/pkgconfig/glib-2.0.pc:glib2 \
- port:gettext \
- port:libiconv
+ port:gettext
archcheck.files-append lib/libglib-2.0.dylib \
- lib/libintl.dylib \
- lib/libiconv.dylib
+ lib/libintl.dylib
configure.args --enable-static \
--disable-introspection
diff --unidirectional-new-file -ru -x 'PortIndex*' ports.orig/devel/gettext/Portfile ports/devel/gettext/Portfile
--- ports.orig/devel/gettext/Portfile 2011-07-25 23:30:20.000000000 -0700
+++ ports/devel/gettext/Portfile 2011-10-13 18:38:08.000000000 -0700
@@ -46,12 +46,10 @@
configure.args-append --without-git \
--without-cvs
-depends_lib port:libiconv \
- port:ncurses \
+depends_lib port:ncurses \
port:expat
-archcheck.files lib/libiconv.dylib \
- lib/libncurses.dylib \
+archcheck.files lib/libncurses.dylib \
lib/libexpat.dylib
test.run yes
diff --unidirectional-new-file -ru -x 'PortIndex*' ports.orig/devel/glib2/Portfile ports/devel/glib2/Portfile
--- ports.orig/devel/glib2/Portfile 2011-07-27 23:30:20.000000000 -0700
+++ ports/devel/glib2/Portfile 2011-10-13 18:38:08.000000000 -0700
@@ -41,12 +41,10 @@
patch-gio_gdbusprivate.c.diff
depends_lib port:gettext \
- port:libiconv \
port:zlib \
path:bin/perl:perl5
archcheck.files lib/libintl.dylib \
- lib/libiconv.dylib \
lib/libz.dylib
use_autoconf yes
diff --unidirectional-new-file -ru -x 'PortIndex*' ports.orig/gnome/gtk2/Portfile ports/gnome/gtk2/Portfile
--- ports.orig/gnome/gtk2/Portfile 2011-09-08 10:30:22.000000000 -0700
+++ ports/gnome/gtk2/Portfile 2011-10-13 19:41:49.000000000 -0700
@@ -43,9 +43,20 @@
path:lib/pkgconfig/pango.pc:pango \
port:gdk-pixbuf2
-depends_run port:shared-mime-info
-
+# If shared-mime-info is installed it causes GTK+ to use Glib's GIO to
+# do automatic file type guessing and to disable its own internal
+# guessing. The guessing then fails at runtime if the MIME database
+# (/usr/share/mime) isn't present. Avoid using GIO and always use GTK+'s
+# internal guesser.
+# depends_run port:shared-mime-info
+
+# Don't have the GDK pixbuf loaders and immodules as loadable modules.
+# This would require running install_name_tool on the .so files to make
+# the libraries they depend on relative to @executable_path, not the
+# MacPorts installation directory.
configure.args --enable-static \
+ --with-included-loaders \
+ --with-included-immodules \
--disable-glibtest \
--disable-introspection \
gio_can_sniff=yes
@@ -87,19 +98,6 @@
xinstall -d ${destroot}${docdir}
xinstall -m 644 -W ${worksrcpath} AUTHORS COPYING HACKING NEWS README \
${destroot}${docdir}
-
- ui_debug "Creating gtk.immodules..."
- system "DYLD_LIBRARY_PATH=${destroot}${prefix}/lib \
- ${destroot}${prefix}/bin/gtk-query-immodules-2.0 \
- ${destroot}${prefix}/lib/gtk-2.0/2.10.0/immodules/*.so \
- >${destroot}${prefix}/etc/gtk-2.0/gtk.immodules"
- reinplace "s|${destroot}||" ${destroot}${prefix}/etc/gtk-2.0/gtk.immodules
-}
-
-post-activate {
- ui_debug "Updating gdk-pixbuf.loaders..."
- system "${prefix}/bin/gdk-pixbuf-query-loaders \
- >${prefix}/etc/gtk-2.0/gdk-pixbuf.loaders"
}
platform darwin 8 {
@@ -115,7 +113,7 @@
}
if {[variant_isset universal]} {
- set cups /usr/bin/cups-config
+ set cups /Developer/SDKs/MacOSX10.5.sdk/usr/bin/cups-config
if {[info exists universal_sysroot]} {
set cups ${universal_sysroot}${cups}
}
diff --unidirectional-new-file -ru -x 'PortIndex*' ports.orig/graphics/fontconfig/Portfile ports/graphics/fontconfig/Portfile
--- ports.orig/graphics/fontconfig/Portfile 2011-05-25 05:00:19.000000000 -0700
+++ ports/graphics/fontconfig/Portfile 2011-10-13 18:38:08.000000000 -0700
@@ -25,12 +25,10 @@
sha1 570fb55eb14f2c92a7b470b941e9d35dbfafa716 \
rmd160 fefee412cad4fa71b573e997e14f1df12f439be2
-depends_lib port:libiconv \
- port:expat \
+depends_lib port:expat \
port:freetype
-archcheck.files lib/libiconv.dylib \
- lib/libexpat.dylib \
+archcheck.files lib/libexpat.dylib \
lib/libfreetype.dylib
set add_fonts /usr/X11R6/lib/X11/fonts
diff --unidirectional-new-file -ru -x 'PortIndex*' ports.orig/perl/p5-locale-gettext/Portfile ports/perl/p5-locale-gettext/Portfile
--- ports.orig/perl/p5-locale-gettext/Portfile 2011-08-15 10:00:54.000000000 -0700
+++ ports/perl/p5-locale-gettext/Portfile 2011-10-13 18:38:08.000000000 -0700
@@ -22,7 +22,7 @@
rmd160 767adfce05b8fe77ddd7d3814951822746cf6e4b
if {${perl5.major} != ""} {
-depends_lib-append port:gettext port:libiconv
+depends_lib-append port:gettext
if {[variant_isset universal]} {
set archflags ${configure.universal_cflags}
diff --unidirectional-new-file -ru -x 'PortIndex*' ports.orig/python/py26-gobject/Portfile ports/python/py26-gobject/Portfile
--- ports.orig/python/py26-gobject/Portfile 2011-09-13 14:00:24.000000000 -0700
+++ ports/python/py26-gobject/Portfile 2011-10-13 18:38:08.000000000 -0700
@@ -35,7 +35,6 @@
depends_lib path:${prefix}/lib/pkgconfig/glib-2.0.pc:glib2 \
port:libxslt \
port:gettext \
- port:libiconv \
port:libffi \
port:python26
diff --unidirectional-new-file -ru -x 'PortIndex*' ports.orig/python/py27-libxml2/files/patch-setup.py.diff ports/python/py27-libxml2/files/patch-setup.py.diff
--- ports.orig/python/py27-libxml2/files/patch-setup.py.diff 2010-11-29 21:30:48.000000000 -0800
+++ ports/python/py27-libxml2/files/patch-setup.py.diff 2011-10-13 18:38:08.000000000 -0700
@@ -1,6 +1,6 @@
--- setup.py.orig 2007-10-11 15:24:20.000000000 +0200
+++ setup.py 2007-10-11 15:24:54.000000000 +0200
-@@ -56,11 +56,7 @@
+@@ -56,11 +56,8 @@
# - iconv.h
# - libxslt/xsltconfig.h
includes_dir = [
@@ -10,6 +10,7 @@
-os.path.join(ROOT,'include'),
-HOME
+"@PREFIX@/include",
++"/Developer/SDKs/MacOSX10.5.sdk/usr/include",
];
xml_includes=""
diff --unidirectional-new-file -ru -x 'PortIndex*' ports.orig/textproc/help2man/Portfile ports/textproc/help2man/Portfile
--- ports.orig/textproc/help2man/Portfile 2011-10-07 20:00:24.000000000 -0700
+++ ports/textproc/help2man/Portfile 2011-10-13 18:38:08.000000000 -0700
@@ -23,7 +23,7 @@
rmd160 dc3f283bceb8216d571ca879a37e7f83255dc412
depends_lib port:perl5.12 port:p5.12-locale-gettext \
- port:gettext port:libiconv
+ port:gettext
configure.perl ${prefix}/bin/perl5.12
diff --unidirectional-new-file -ru -x 'PortIndex*' ports.orig/textproc/libxml2/Portfile ports/textproc/libxml2/Portfile
--- ports.orig/textproc/libxml2/Portfile 2011-07-13 12:00:20.000000000 -0700
+++ ports/textproc/libxml2/Portfile 2011-10-13 18:38:08.000000000 -0700
@@ -21,10 +21,9 @@
sha1 859dd535edbb851cc15b64740ee06551a7a17d40 \
rmd160 30709622cfe3e2175e73d6701b7e19a25ab5ac47
-depends_lib port:libiconv port:zlib
+depends_lib port:zlib
-archcheck.files lib/libiconv.dylib \
- lib/libz.dylib
+archcheck.files lib/libz.dylib
post-extract {
reinplace "s|/etc|${prefix}/etc|g" \
diff --unidirectional-new-file -ru -x 'PortIndex*' ports.orig/textproc/libxslt/Portfile ports/textproc/libxslt/Portfile
--- ports.orig/textproc/libxslt/Portfile 2011-07-07 08:30:19.000000000 -0700
+++ ports/textproc/libxslt/Portfile 2011-10-13 18:38:08.000000000 -0700
@@ -30,8 +30,7 @@
sha1 69f74df8228b504a87e2b257c2d5238281c65154 \
rmd160 fc7630352ae5772d25fc8132a373d477fb8d8d5f
-depends_lib port:libiconv \
- port:libxml2 \
+depends_lib port:libxml2 \
port:zlib
configure.args --mandir=${prefix}/share/man \
diff --unidirectional-new-file -ru -x 'PortIndex*' ports.orig/x11/pango/Portfile ports/x11/pango/Portfile
--- ports.orig/x11/pango/Portfile 2011-07-29 19:00:21.000000000 -0700
+++ ports/x11/pango/Portfile 2011-10-13 19:35:24.000000000 -0700
@@ -102,6 +102,7 @@
configure.args \
--enable-static \
+ --with-included-modules \
--disable-introspection \
--without-x

View File

@@ -0,0 +1,94 @@
This is a description of the files in this directory, all of which have
to do with packaging on Mac OS X. They are useful only for those wanting
to build binary distributions of Zenmap for Mac OS X.
== Info.plist
A properties list file that whose contents are merged with the default
properties added by py2app.
== make-bundle.sh
This script builds a .app bundle. It must be run from the root of the
Zenmap source tree. The finished bundle is put in dist/Zenmap.app.
== test_wrapper.py
This file contains unit tests for zenmap_wrapper.py, because it needs to
do some tricky escaping and substitution of configuration files.
== zenmap.icns
The icon file for the bundle. It was created using the Icon Composer
utility as described at
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/08Configuring/08Configuring.html
== zenmap_auth.c
This is a simple wrapper program that attempts to run zenmap_wrapper.py
with privileges.
== zenmap_wrapper.py
This is a wrapper script that gets installed in the application bundle.
It sets up an execution environment and then calls the main zenmap
executable.
== MacPorts-ports.diff
This patch against a MacPorts ports tree contains various changes needed
to install dependencies in a sufficiently portable way. The main thing
accomplished by this patch is to avoid building a MacPorts libiconv.
libcups depends on libiconv, but it depends on an Apple version of
libconv, and MacPorts doesn't have a port for libcups. The MacPorts
libiconv is incompatible and causes a dynamic linker error at runtime.
The following instructions show how to make a 10.5-compatible
environment suitable for building Zenmap packages. It will be a separate
installation in $HOME/macports-10.5 that won't interfere with your
normal MacPorts installation in /opt/local. These instructions were done
with MacPorts 2.0.3 on Mac OS X 10.6.8.
1. Install MacPorts.
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
export PREFIX=$HOME/macports-10.5
tar xzvf MacPorts-2.0.3.tar.gz
cd MacPorts-2.0.3
./configure --with-no-root-privileges --prefix=$PREFIX --with-tclpackage=$PREFIX/Library/Tcl --with-applications-dir=$PREFIX/Applications
make
make install
2. Update the ports tree.
$PREFIX/bin/port sync
3. Edit the file $PREFIX/etc/macports/macports.conf.
Uncomment the line
build_arch i386
Add this line at the bottom:
macosx_deployment_target 10.5
4. Make a local patched ports tree.
cd $PREFIX
mkdir ports
ln -s var/macports/sources/rsync.macports.org/release/tarballs/ports ports.orig
for x in devel/atk devel/gettext devel/glib2 gnome/gtk2 graphics/fontconfig perl/p5-locale-gettext python/py26-gobject python/py27-libxml2 textproc/help2man textproc/libxml2 textproc/libxslt; do
mkdir -v -p ports/$x;
cp -R ports.orig/$x ports/$(dirname $x);
done
patch -p0 < MacPorts-ports.diff
5. Build a port index.
cd ports
$PREFIX/bin/portindex
6. Edit the file $PREFIX/etc/macports/sources.conf.
Add a line
file:///Users/user/macports-10.5/ports
above the rsync line. (Replace "user" with your user name.)
7. Install the dependencies of Zenmap.
$PREFIX/bin/port install py26-gtk py26-py2app
Here are instructions for updating the patch to keep up with MacPorts
changes. First, sync the original ports tree.
$PREFIX/bin/port sync
Restore a pristine partial ports tree:
cd $PREFIX
rsync -rv --existing --delete --exclude=PortIndex ports.orig/ ports/
Reapply the patch. Resolve any conflicts.
patch -p0 --no-backup-if-mismatch < MacPorts-ports.diff
Make a new patch.
diff --unidirectional-new-file -ru -x 'PortIndex*' ports.orig ports | grep -v '^Only in ' > new.diff
Check that it's all right, then rename it.
mv new.diff MacPorts-ports.diff
Rebuild the port index.
cd ports
$PREFIX/bin/portindex

View File

@@ -0,0 +1,3 @@
# Use Lucida Grande, the face used by other OS X applications.
gtk-font-name="Lucida Grande"

View File

@@ -0,0 +1,84 @@
#!/bin/sh -e
# make-bundle.sh
# David Fifield
#
# This script works the magic needed to build Zenmap into a .app bundle for Mac
# OS X. It's complicated because py2app doesn't really support Pango or PyGTK.
#
# It is based on the osx-app.sh script used by Wireshark, which contains the
# following notice:
#
# AUTHORS
# Kees Cook <kees@outflux.net>
# Michael Wybrow <mjwybrow@users.sourceforge.net>
# Jean-Olivier Irisson <jo.irisson@gmail.com>
#
# Copyright (C) 2005 Kees Cook
# Copyright (C) 2005-2007 Michael Wybrow
# Copyright (C) 2007 Jean-Olivier Irisson
#
# Released under GNU GPL, read the file 'COPYING' for more information
# This script relies on having an installation of MacPorts in $(LIBPREFIX),
# configured as you wish. See README for instructions on how to make a build
# environment. You need to have installed the packages py26-gtk and
# py26-py2app.
LIBPREFIX=$HOME/macports-10.5
PYTHON=$LIBPREFIX/bin/python2.6
PKG_CONFIG=$LIBPREFIX/bin/pkg-config
APP_NAME=Zenmap
BASE=dist/$APP_NAME.app/Contents
SCRIPT_DIR=`dirname "$0"`
CC=${CC:-gcc}
CFLAGS=${CFLAGS:--Wall}
echo "Running $0."
echo "Removing old build."
rm -rf build dist
echo "Compiling using py2app."
$PYTHON setup.py py2app --no-strip
mkdir -p $BASE/Resources/etc
mkdir -p $BASE/Resources/lib
gtk_version=`$PKG_CONFIG --variable=gtk_binary_version gtk+-2.0`
echo "Copying GTK+ $gtk_version files."
mkdir -p $BASE/Resources/lib/gtk-2.0/$gtk_version
cp -R $LIBPREFIX/lib/gtk-2.0/$gtk_version/* $BASE/Resources/lib/gtk-2.0/$gtk_version/
mkdir -p $BASE/Resources/etc/gtk-2.0
cp $SCRIPT_DIR/gtkrc $BASE/Resources/etc/gtk-2.0/
pango_version=`$PKG_CONFIG --variable=pango_module_version pango`
echo "Copying Pango $pango_version files."
mkdir -p $BASE/Resources/etc/pango
cat > $BASE/Resources/etc/pango/pangorc.in <<EOF
# This template is filled in at run time by the application.
[PangoX]
AliasFiles = \${RESOURCES}/etc/pango/pangox.aliases
EOF
cp $LIBPREFIX/etc/pango/pangox.aliases $BASE/Resources/etc/pango/
echo "Copying Fontconfig files."
cp -R $LIBPREFIX/etc/fonts $BASE/Resources/etc/
# Remove the dir and cachedir under $LIBPREFIX. The cachedir ~/.fontconfig remains.
sed -i "" 's/ *<dir>'$(echo "$LIBPREFIX" | sed -e 's/\([^a-zA-Z0-9]\)/\\\1/g')'\/share\/fonts<\/dir>//g' $BASE/Resources/etc/fonts/fonts.conf
sed -i "" '/<cachedir>'$(echo "$LIBPREFIX" | sed -e 's/\([^a-zA-Z0-9]\)/\\\1/g')'\/var\/cache\/fontconfig<\/cachedir>/d' $BASE/Resources/etc/fonts/fonts.conf
# Disable hinting to better match the Mac GUI.
ln -sf ../conf.avail/10-unhinted.conf $BASE/Resources/etc/fonts/conf.d
echo "Renaming main Zenmap executable."
mv $BASE/MacOS/$APP_NAME $BASE/MacOS/zenmap.bin
echo "Installing wrapper script."
cp $SCRIPT_DIR/zenmap_wrapper.py $BASE/MacOS/
echo "Compiling and installing authorization wrapper."
echo $CC $CPPFLAGS $CFLAGS $LDFLAGS -framework Security -o $BASE/MacOS/$APP_NAME $SCRIPT_DIR/zenmap_auth.c
$CC $CPPFLAGS $CFLAGS $LDFLAGS -framework Security -o $BASE/MacOS/$APP_NAME $SCRIPT_DIR/zenmap_auth.c

View File

@@ -0,0 +1,32 @@
#!/usr/bin/env python
# This is a test class for the non-trivial escaping done by zenmap_wrapper.py.
import unittest
import zenmap_wrapper
class test_key_file(unittest.TestCase):
def test_escape(self):
TESTS = (
("", ""),
("a", "a"),
("a\nb\tc\rd\\e", "a\\nb\\tc\\rd\\\\e"),
("a\"b", "a\"b")
)
for test_line, expected in TESTS:
actual = zenmap_wrapper.escape_key_file_value(test_line)
self.assertEqual(expected, actual)
def test_escape_first_space(self):
# Check first-character space escaping.
self.assert_(zenmap_wrapper.escape_key_file_value(" abc").startswith("\\s"))
def test_substitute(self):
original = "abc"
replacements = {"b": "\"\\\t\r\ndef"}
expected = "a\"\\\\\\t\\r\\ndefc"
actual = zenmap_wrapper.substitute_key_file_line(original, replacements)
self.assertEqual(expected, actual)
unittest.main()

Binary file not shown.

View File

@@ -0,0 +1,73 @@
/*
This program attempts to run the program EXECUTABLE_NAME in the same
directory as itself using AuthorizationExecuteWithPrivileges. If the
authorization fails or is canceled, EXECUTABLE_NAME is run without
privileges using a plain exec.
This program is the first link in the chain
zenmap_auth -> zenmap_wrapper.py -> zenmap.bin
*/
#include <errno.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <Security/Authorization.h>
#include <Security/AuthorizationTags.h>
#define EXECUTABLE_NAME "zenmap_wrapper.py"
int main(int argc, char *argv[]) {
AuthorizationItem items[] = {
{ kAuthorizationRightExecute, 0, NULL, 0 }
};
AuthorizationRights rights = { 1, items };
AuthorizationRef ref;
AuthorizationFlags flags;
OSStatus status;
char executable_path[1024];
const char *cwd;
size_t len_cwd;
int return_code;
cwd = dirname(argv[0]);
len_cwd = strlen(cwd);
if (sizeof(executable_path) < len_cwd + strlen("/") + strlen(EXECUTABLE_NAME) + 1) {
fprintf(stderr, "Not enough room to store executable path: %s\n", strerror(errno));
exit(1);
}
strcpy(executable_path, cwd);
executable_path[len_cwd] = '/';
strcpy(executable_path + len_cwd + 1, EXECUTABLE_NAME);
flags = kAuthorizationFlagDefaults
| kAuthorizationFlagInteractionAllowed
| kAuthorizationFlagPreAuthorize
| kAuthorizationFlagExtendRights;
status = AuthorizationCreate(&rights, kAuthorizationEmptyEnvironment, flags, &ref);
if (status != errAuthorizationSuccess) {
if (status != errAuthorizationCanceled)
fprintf(stderr, "Couldn't create authorization reference (status code %ld).\n", status);
errno = 0;
execv(executable_path, argv);
fprintf(stderr, "Couldn't exec '%s': %s.\n", executable_path, strerror(errno));
exit(1);
}
status = AuthorizationExecuteWithPrivileges(ref, executable_path,
kAuthorizationFlagDefaults, argv + 1, NULL);
AuthorizationFree(ref, kAuthorizationFlagDefaults);
if (status != errAuthorizationSuccess) {
fprintf(stderr, "Couldn't execute '%s' with privileges (status code %ld).\n", executable_path, status);
errno = 0;
execv(executable_path, argv);
fprintf(stderr, "Couldn't exec '%s': %s.\n", executable_path, strerror(errno));
exit(1);
}
wait(&return_code);
exit(return_code);
}

View File

@@ -0,0 +1,174 @@
#!/usr/bin/env python
# This is a wrapper script around the zenmap executable, used in a Mac OS X .app
# bundle. It sets environment variables, fills in template configuration files,
# starts X11 if necessary, and execs the real zenmap executable.
#
# This program is the second link in the chain
# zenmap_auth -> zenmap_wrapper.py -> zenmap.bin
import errno
import os
import os.path
import sys
HOME = os.path.expanduser("~")
def create_dir(path):
"""Create a directory with os.makedirs without raising an error if the
directory already exists."""
try:
os.makedirs(path)
except OSError, e:
if e.errno != errno.EEXIST:
raise
# We will need to rewrite some configuration files to refer to directories
# inside the application bundle, wherever it may be. This is tricky because of
# escaping issues in the formats of the configuration files. The following
# functions handle it.
# The format of pango/pangorc is called "key file." It's described at
# http://library.gnome.org/devel/glib/stable/glib-Key-value-file-parser.
# Escape a string as approprite for a "key file."
def escape_key_file_value(value):
result = []
for c in value:
if c == "\n":
c = "\\n"
elif c == "\t":
c = "\\t"
elif c == "\r":
c = "\\r"
elif c == "\\":
c = "\\\\"
result.append(c)
if len(result) > 0 and result[0] == " ":
result[0] = "\\s"
result = "".join(result)
return result
def substitute_key_file_line(line, replacements):
for text, rep in replacements.items():
line = line.replace(text, escape_key_file_value(rep))
return line
# Substitute a dict of replacements into a "key file."
def substitute_key_file(in_file_name, out_file_name, replacements):
in_file = open(in_file_name, "r")
out_file = open(out_file_name, "w")
for line in in_file:
out_file.write(substitute_key_file_line(line, replacements))
in_file.close()
out_file.close()
def escape_shell(arg):
"""Escape a string to be a shell argument."""
result = []
for c in arg:
if c in "$`\"\\":
c = "\\" + c
result.append(c)
return "\"" + "".join(result) + "\""
def hack_xinitrc(system_xinitrc_filename, home_xinitrc_filename):
"""Hack the system xinitrc file and put the modified contents into another
file. The parameter names reflect the fact that this is intended to copy
the system xinitrc into ~/.xinitrc. The modified xinitrc will delete itself
on its first invocation and will not run any instances of xterm. This is
necessary on Mac OS X 10.4 and earlier, which include a call to xterm in
the system xinitrc."""
system_xinitrc = open(system_xinitrc_filename, "r")
home_xinitrc = open(home_xinitrc_filename, "w")
lines = iter(system_xinitrc)
# Look for the first non-comment line so we don't pre-empt the #! line.
for line in lines:
if not line.lstrip().startswith("#"):
break
home_xinitrc.write(line)
# Write the self-destruct line.
home_xinitrc.write("\n")
home_xinitrc.write("rm -f %s\n" % escape_shell(home_xinitrc_filename))
home_xinitrc.write(line)
# Copy the rest, removing any calls to xterm
for line in lines:
if line.lstrip().startswith("xterm"):
line = "# " + line
home_xinitrc.write(line)
system_xinitrc.close()
home_xinitrc.close()
def start_x11():
"""Start the X11 server if necessary and set the DISPLAY environment as
appropriate. If the user hasn't set up a custom ~/.xinitrc, call
hack_xinitrc to make a ~/.xinitrc that will not start an xterm along with
the application. A similar approach is taken by Wireshark and Inkscape."""
if os.environ.has_key("DISPLAY"):
return
system_xinitrc_filename = "/usr/X11R6/lib/X11/xinit/xinitrc"
home_xinitrc_filename = os.path.join(HOME, ".xinitrc")
if not os.path.exists(home_xinitrc_filename):
hack_xinitrc(system_xinitrc_filename, home_xinitrc_filename)
os.system("open -a X11")
os.environ["DISPLAY"] = ":0"
if __name__ == "__main__":
# Make the real UID equal the effective UID. They are unequal when running
# with privileges under AuthorizationExecuteWithPrivileges. GTK+ refuses to
# run if they are different.
if os.getuid() != os.geteuid():
os.setuid(os.geteuid())
# Paths within the application bundle.
currentdir = os.path.dirname(os.path.abspath(sys.argv[0]))
parentdir = os.path.dirname(currentdir)
resourcedir = os.path.join(parentdir, "Resources")
# A directory where we put automatically generated GTK+ and Pango files.
# This could be something different like /tmp or "~/Library/Application
# Support/Zenmap". It is put somewhere other than within the application
# bundle to allow running from a read-only filesystem.
etcdir = os.path.join(HOME, ".zenmap-etc")
# Override the dynamic library search path. This makes the various GTK+ and
# Pango shared objects look at the bundled copies of the libraries. py2app
# puts .dylibs in Contents/Frameworks.
os.environ["DYLD_LIBRARY_PATH"] = os.path.join(parentdir, "Frameworks")
# See http://library.gnome.org/devel/gtk/2.12/gtk-running.html for the
# meaning of the GTK+ environment variables. These files are static and
# live inside the application bundle.
os.environ["GTK_DATA_PREFIX"] = resourcedir
os.environ["GTK_EXE_PREFIX"] = resourcedir
os.environ["GTK_PATH"] = resourcedir
os.environ["FONTCONFIG_PATH"] = os.path.join(resourcedir, "etc", "fonts")
# Use the packaged gtkrc only if the user doesn't have a custom one.
if not os.path.exists(os.path.expanduser("~/.gtkrc-2.0")):
os.environ["GTK2_RC_FILES"] = os.path.join(resourcedir, "etc", "gtk-2.0", "gtkrc")
# The following environment variables refer to files within ~/.zenmap-etc
# that are automatically generated from templates.
os.environ["PANGO_RC_FILE"] = os.path.join(etcdir, "pango", "pangorc")
# Create the template directory.
create_dir(os.path.join(etcdir, "pango"))
REPLACEMENTS = {
"${RESOURCES}": resourcedir,
"${ETC}": etcdir
}
# Fill in the templated configuration files with the correct substitutions.
KEY_FILE_TEMPLATES = (
"pango/pangorc",
)
for f in KEY_FILE_TEMPLATES:
in_file_name = os.path.join(resourcedir, "etc", f + ".in")
out_file_name = os.path.join(etcdir, f)
substitute_key_file(in_file_name, out_file_name, REPLACEMENTS)
start_x11()
# exec the real program.
os.execl(os.path.join(os.path.dirname(sys.argv[0]), "zenmap.bin"), *sys.argv)

View File

@@ -0,0 +1,51 @@
#!/bin/bash
#this code is bassed off of the debian su-to-root command
#Joost Witteveen <joostje@debian.org>
#Morten Brix Pedersen
#Bill Allombert <ballombe@debian.org>
PRIV=root
COMMAND="zenmap $@"
euid=$(id -u)
privid=$(id -u $PRIV)
if test "$euid" = "$privid"; then
$COMMAND
else
if test -z "$SU_TO_ROOT_X"; then
if which gksu >/dev/null 2>&1 ; then
SU_TO_ROOT_X=gksu
if test "X$KDE_FULL_SESSION" = "Xtrue" ; then
if which kdesu >/dev/null 2>&1 ; then
SU_TO_ROOT_X=kdesu
elif test -x /usr/lib/kde4/libexec/kdesu ; then
SU_TO_ROOT_X=kde4su
fi;
fi;
elif which kdesu >/dev/null 2>&1 ; then
SU_TO_ROOT_X=kdesu
elif test -x /usr/lib/kde4/libexec/kdesu ; then
SU_TO_ROOT_X=kde4su
elif which ktsuss >/dev/null 2>&1 ; then
SU_TO_ROOT_X=ktsuss
elif which xterm>/dev/null 2>&1 ;then
if which sudo>/dev/null 2>&1 ;then
SU_TO_ROOT_X=sdterm
else
SU_TO_ROOT_X=sterm
fi;
else
SU_TO_ROOT_X=su-to-root
fi
fi
case $SU_TO_ROOT_X in
gksu) gksu -u "$PRIV" "$COMMAND";;
kdesu) kdesu -u "$PRIV" "$COMMAND";;
kde4su) /usr/lib/kde4/libexec/kdesu -u "$PRIV" "$COMMAND";;
ktsuss) ktsuss -u "$PRIV" "$COMMAND";;
# As a last resort, open a new xterm use sudo/su
sdterm) xterm -e "sudo -u $PRIV $COMMAND";;
sterm) xterm -e "su -l $PRIV -c $COMMAND";;
esac;
fi

View File

@@ -0,0 +1,11 @@
[Desktop Entry]
Encoding=UTF-8
Name=Zenmap (as root)
GenericName=GUI Port Scanner
TryExec=su-to-zenmap.sh
Exec=su-to-zenmap.sh %F
Terminal=false
Icon=zenmap
Type=Application
Categories=Application;Network;Security
Comment=A cross-platform GUI for the Nmap Security Scanner.

View File

@@ -0,0 +1,11 @@
[Desktop Entry]
Encoding=UTF-8
Name=Zenmap
GenericName=GUI Port Scanner
TryExec=zenmap
Exec=zenmap %F
Terminal=false
Icon=zenmap
Type=Application
Categories=Application;Network;Security
Comment=A cross-platform GUI for the Nmap Security Scanner.

View File

@@ -0,0 +1,117 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ***********************IMPORTANT NMAP LICENSE TERMS************************
# * *
# * The Nmap Security Scanner is (C) 1996-2011 Insecure.Com LLC. Nmap is *
# * also a registered trademark of Insecure.Com LLC. This program is free *
# * software; you may redistribute and/or modify it under the terms of the *
# * GNU General Public License as published by the Free Software *
# * Foundation; Version 2 with the clarifications and exceptions described *
# * below. This guarantees your right to use, modify, and redistribute *
# * this software under certain conditions. If you wish to embed Nmap *
# * technology into proprietary software, we sell alternative licenses *
# * (contact sales@insecure.com). Dozens of software vendors already *
# * license Nmap technology such as host discovery, port scanning, OS *
# * detection, and version detection. *
# * *
# * Note that the GPL places important restrictions on "derived works", yet *
# * it does not provide a detailed definition of that term. To avoid *
# * misunderstandings, we consider an application to constitute a *
# * "derivative work" for the purpose of this license if it does any of the *
# * following: *
# * o Integrates source code from Nmap *
# * o Reads or includes Nmap copyrighted data files, such as *
# * nmap-os-db or nmap-service-probes. *
# * o Executes Nmap and parses the results (as opposed to typical shell or *
# * execution-menu apps, which simply display raw Nmap output and so are *
# * not derivative works.) *
# * o Integrates/includes/aggregates Nmap into a proprietary executable *
# * installer, such as those produced by InstallShield. *
# * o Links to a library or executes a program that does any of the above *
# * *
# * The term "Nmap" should be taken to also include any portions or derived *
# * works of Nmap. This list is not exclusive, but is meant to clarify our *
# * interpretation of derived works with some common examples. Our *
# * interpretation applies only to Nmap--we don't speak for other people's *
# * GPL works. *
# * *
# * If you have any questions about the GPL licensing restrictions on using *
# * Nmap in non-GPL works, we would be happy to help. As mentioned above, *
# * we also offer alternative license to integrate Nmap into proprietary *
# * applications and appliances. These contracts have been sold to dozens *
# * of software vendors, and generally include a perpetual license as well *
# * as providing for priority support and updates as well as helping to *
# * fund the continued development of Nmap technology. Please email *
# * sales@insecure.com for further information. *
# * *
# * As a special exception to the GPL terms, Insecure.Com LLC grants *
# * permission to link the code of this program with any version of the *
# * OpenSSL library which is distributed under a license identical to that *
# * listed in the included docs/licenses/OpenSSL.txt file, and distribute *
# * linked combinations including the two. You must obey the GNU GPL in all *
# * respects for all of the code used other than OpenSSL. If you modify *
# * this file, you may extend this exception to your version of the file, *
# * but you are not obligated to do so. *
# * *
# * If you received these files with a written license agreement or *
# * contract stating terms other than the terms above, then that *
# * alternative license agreement takes precedence over these comments. *
# * *
# * Source is provided to this software because we believe users have a *
# * right to know exactly what a program is going to do before they run it. *
# * This also allows you to audit the software for security holes (none *
# * have been found so far). *
# * *
# * Source code also allows you to port Nmap to new platforms, fix bugs, *
# * and add new features. You are highly encouraged to send your changes *
# * to nmap-dev@insecure.org for possible incorporation into the main *
# * distribution. By sending these changes to Fyodor or one of the *
# * Insecure.Org development mailing lists, it is assumed that you are *
# * offering the Nmap Project (Insecure.Com LLC) the unlimited, *
# * non-exclusive right to reuse, modify, and relicense the code. Nmap *
# * will always be available Open Source, but this is important because the *
# * inability to relicense code has caused devastating problems for other *
# * Free Software projects (such as KDE and NASM). We also occasionally *
# * relicense the code to third parties as discussed above. If you wish to *
# * specify special license conditions of your contributions, just say so *
# * when you send them. *
# * *
# * This program is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * General Public License v2.0 for more details at *
# * http://www.gnu.org/licenses/gpl-2.0.html , or in the COPYING file *
# * included with Nmap. *
# * *
# ***************************************************************************/
# This program updates the version number in all the places it needs to be
# updated. It takes a single command-line argument, which is the new version
# number. For example:
# python install_scripts/utils/version_update.py X.YY
import os
import sys
VERSION = os.path.join("share", "zenmap", "config", "zenmap_version")
VERSION_PY = os.path.join("zenmapCore", "Version.py")
def update_version(base_dir, version):
print ">>> Updating %s" % os.path.join(base_dir, VERSION)
vf = open(os.path.join(base_dir, VERSION), "wb")
print >> vf, version
vf.close()
print ">>> Updating %s" % os.path.join(base_dir, VERSION_PY)
vf = open(os.path.join(base_dir, VERSION_PY), "w")
print >> vf, "VERSION = \"%s\"" % version
vf.close()
if __name__ == "__main__":
if len(sys.argv) != 2:
print >> sys.stderr, "Usage: %s <version>" % sys.argv[0]
sys.exit(1)
version = sys.argv[1]
print ">>> Updating version number to \"%s\"" % version
update_version(".", version)

View File

@@ -0,0 +1,56 @@
@echo off
echo Setting installation variables...
set PythonDir=C:\Python27
set PythonEXE=%PythonDir%\python.exe
set DistDir=dist
set LibraryDir=%DistDir%\py2exe
set GTKDir=%PythonDir%\Lib\site-packages\gtk-2.0\runtime
set Output=win_install.log
IF EXIST %PythonEXE% GOTO GGTK
ECHO No Python found!
EXIT 1
:GGTK
IF EXIST %GTKDir% GOTO GWork
ECHO No GTK found!
EXIT 1
:GWork
echo Writing output to %Output%
echo Removing old compilation...
IF EXIST %DistDir% rd %DistDir% /s /q > %Output%
echo Creating dist directory tree...
mkdir %LibraryDir%\etc
mkdir %LibraryDir%\share
mkdir %LibraryDir%\share\themes
mkdir %LibraryDir%\lib
echo Copying GTK files to dist directory...
xcopy %GTKDir%\bin\*.dll %LibraryDir% /S >> %Output%
rem intl.dll is a special case; has to be in the executable directory instead of
rem the py2exe subdirectory.
move /Y %LibraryDir%/intl.dll %DistDir% >> %Output%
xcopy %GTKDir%\etc %LibraryDir%\etc /S /I >> %Output%
xcopy %GTKDir%\lib\gtk-2.0 %LibraryDir%\lib\gtk-2.0 /S /I >> %Output%
xcopy %GTKDir%\share\themes\Default %LibraryDir%\share\themes\Default /S /I >> %Output%
xcopy %GTKDir%\share\themes\MS-Windows %LibraryDir%\share\themes\MS-Windows /S /I >> %Output%
echo Compiling using py2exe...
%PythonEXE% setup.py py2exe >> %Output%
echo Removing the build directory...
rd build /s /q >> %Output%
rem Check that the gtkrc file was manually created so Zenmap will look pretty
IF EXIST %DistDir%\etc\gtk-2.0\gtkrc GOTO gtkrc
echo gtk-theme-name = "MS-Windows" > %DistDir%\py2exe\etc\gtk-2.0\gtkrc
echo Created the missing file %DistDir%\py2exe\etc\gtk-2.0\gtkrc >> %Output%
:gtkrc
echo Done!

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB