Changeset 680
- Timestamp:
- 10/27/06 05:41:44 (2 years ago)
- Files:
-
- honeybow/trunk/mwsubmitter/CHANGELOG (modified) (2 diffs)
- honeybow/trunk/mwsubmitter/src/mwsubmitter (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
honeybow/trunk/mwsubmitter/CHANGELOG
r671 r680 1 2006-10-27 2 v0.1.1 3 1. Added support for multiple files submission. 4 2. Removed -d option and now the sample directory is given as a arguement. 5 1 6 2006-10-18 2 7 v0.1.0 … … 6 11 v0.0.9b 7 12 1. Added -D option for future HoneyBow shell-script. 8 2. Fixed a 'bug' caused by GOTEK client while submit tingempty file.9 3. Fixed a submi ttingdisplay bug.13 2. Fixed a 'bug' caused by GOTEK client while submits empty file. 14 3. Fixed a submission display bug. 10 15 4. Added GOTEK client recompilation in install script. honeybow/trunk/mwsubmitter/src/mwsubmitter
r671 r680 6 6 # Copyright (C) 2006 Artmeis: Chinese Honeynet Project 7 7 # 8 # Version 0.1. 08 # Version 0.1.1 9 9 # 10 10 # This program is free software; you can redistribute it and/or modify … … 26 26 # Usage: mwsubmitter [-c config-file] [-D] -b 27 27 # mwsubmitter [-c config-file] [-t cycle] -m 28 # mwsubmitter -s server-address [-p port] [-D] - d scan-dir -u user-name -k key-file28 # mwsubmitter -s server-address [-p port] [-D] -u user-name -k key-file {sample-dir|sample-file[s]} 29 29 # mwsubmitter -v 30 30 # mwsubmitter -h 31 31 # 32 # -s MwCollector (or any other G.O.T.E.K. campatible server)address.33 # -p MwCollector'sport.32 # -s G.O.T.E.K. server address. 33 # -p G.O.T.E.K. server port. 34 34 # -c Use <config-file> as monitor directory set, use $HOME/.mwsubmitter/config 35 35 # as default. Read MwSubmitter Manual for more information about MwSubmitter's … … 39 39 # -t Scan cycle in monitor mode. 40 40 # -m Use monitor mode, implicitly contain -D option. 41 # -d Scan directory, scan only once.42 41 # -u User name for submit authentication. 43 42 # -k Correspond key file for submit authentication. … … 48 47 # 49 48 # Please write to songchengyu@icst.pku.edu.cn 49 # or cs@mwcollect.org 50 50 # 51 51 ########################################################################### … … 53 53 #! /bin/bash 54 54 55 version="0.1. 0"55 version="0.1.1" 56 56 57 57 submit_sample() { 58 local user="$1" 59 local keyfile="$2" 60 local sample_dir="$3" 61 58 local sample_dir="$1" 59 local file 60 local line 61 local new_name 62 62 63 #if there are samples 63 64 if [ -n "$(ls -1 "$sample_dir")" ]; then … … 76 77 77 78 echo "Submitting..." 78 for file in "$sample_dir"/* 79 do 79 for file in "$sample_dir"/*; do 80 80 if [ ! -s "$file" ]; then 81 echo "Clean empty file $file" 81 82 rm -f "$file" 82 continue 83 fi 84 85 echo -n "Submitting $file ... " 86 if [ -z $port ]; then 87 "$gotekc_path" -k "$keyfile" -u "$user" -s "$server" -f "$file" 2>&1 > /dev/null 88 else 89 "$gotekc_path" -k "$keyfile" -u "$user" -s "$server" -p "$port" -f "$file" 2>&1 > /dev/null 90 fi 91 result=$? 92 93 if (($result == 0 || $result == 2)); then 94 echo "Succeed" 95 96 if (($doDelete == 1)); then 97 rm -f "$file" 98 fi 99 else 100 echo "Failed" 101 102 if ((monitor == 1)); then 103 if [ -z "$(echo "$file" | grep '#_#')" ]; then 104 new_file="$file""#_#"`date +%G%m%d%H%M` 105 mv "$file" "$new_file" 106 fi 107 fi 108 fi 109 83 continue 84 fi 85 86 submit_file "$file" 110 87 done 111 88 fi … … 113 90 } 114 91 92 submit_file (){ 93 local file="$1" 94 local new_file 95 96 echo -n "Submitting $file ... " 97 98 if [ -z $port ]; then 99 "$gotekc_path" --key "$key" --user "$name" --server "$server" --file "$file" 2>&1 > /dev/null 100 else 101 "$gotekc_path" --key "$key" --user "$name" --server "$server" --port "$port" --file "$file" 2>&1 > /dev/null 102 fi 103 result=$? 104 105 if (($result == 0 || $result == 2)); then 106 echo "Succeed" 107 108 if (($doDelete == 1)); then 109 rm -f "$1" 110 fi 111 else 112 echo "Failed" 113 114 if ((monitor == 1)); then 115 if [ -z "$(echo "$file" | grep '#_#')" ]; then 116 new_file="$file""#_#"`date +%G%m%d%H%M` 117 mv "$file" "$new_file" 118 fi 119 fi 120 fi 121 } 122 115 123 process (){ 124 local dir 125 116 126 while read server port; do 117 127 if [ -z "$(echo $server | grep ^#)" ]; then … … 135 145 fi 136 146 137 submit_sample "$ name" "$key" "$dir"147 submit_sample "$dir" 138 148 done 139 149 } … … 142 152 echo "Usage: $PROGRAM [-c config-file] [-D] -b" 143 153 echo " $PROGRAM [-c config-file] [-t cycle] -m" 144 echo " $PROGRAM -s server-address [-p port] [-D] - d scan-dir -u user-name -k key-file"154 echo " $PROGRAM -s server-address [-p port] [-D] -u user-name -k key-file {dir|file[s]}" 145 155 echo " $PROGRAM -v" 146 156 echo " $PROGRAM -h" 147 echo -e "\n\t-s MwCollector (or any other G.O.T.E.K. campatible server)address."148 echo -e "\t-p MwCollector port."157 echo -e "\n\t-s G.O.T.E.K. server address." 158 echo -e "\t-p G.O.T.E.K. server port." 149 159 echo -e "\t-c Use <config-file> as monitor directory set, use $HOME/.mwsubmitter/config. \n\t as default. Read MwSubmitter Manual for more information about MwSubmitter's \n\t config-file." 150 160 echo -e "\t-D Delete samples after successful submit." … … 152 162 echo -e "\t-t Scan cycle in monitor mode." 153 163 echo -e "\t-m Use monitor mode, implicitly contain -D option." 154 echo -e "\t-d Scan directory, scan only once."155 164 echo -e "\t-u User name for submit authentication." 156 165 echo -e "\t-k Correspond key file for submit authentication." … … 186 195 fi 187 196 188 while getopts ":s:p:c:bt:m d:u:k:Dvh" opt; do197 while getopts ":s:p:c:bt:mu:k:Dvh" opt; do 189 198 case $opt in 190 199 s ) server="$OPTARG" ;; … … 201 210 202 211 m ) monitor=1 ;; 203 204 d ) dir="$OPTARG" ;;205 212 206 213 u ) name="$OPTARG" ;; … … 225 232 cycle=${cycle:-1200} 226 233 cfg_file=${cfg_file:-"$HOME/.mwsubmitter/config"} 227 gotekc_path= /usr/bin/gotekc234 gotekc_path="/usr/local/bin/gotekc" 228 235 doDelete=${doDelete:-0} 229 236 … … 233 240 234 241 if [ ! -x $gotekc_path ]; then 235 echo "$PROGRAM: G.O.T.E.K. client not found, please reinstall MwSubmitter."242 echo "$PROGRAM: G.O.T.E.K. client not found, please reinstall gotekc." 236 243 exit 1 237 244 fi … … 266 273 fi 267 274 268 if [ -z $dir ]; then269 echo "$PROGRAM: scan directory not specified."270 exit 1271 fi272 275 if [ -z $name ]; then 273 276 echo "$PROGRAM: user name not specified." 274 277 exit 1 275 278 fi 276 if [ -z $key]; then279 if [ -z "$key" ]; then 277 280 echo "$PROGRAM: key file not specified" 278 exit 1279 fi280 281 if [ ! -d "$dir" ]; then282 echo "$PROGRAM: scan directory does not exist"283 281 exit 1 284 282 fi … … 289 287 fi 290 288 291 submit_sample "$name" "$key" "$dir" 292 date 289 if [ -z "$*" ]; then 290 echo "$PROGRAM: no submitter dir or file specified" 291 exit 1 292 fi 293 294 if [ -d "$1" ]; then 295 submit_sample "$1" 296 exit 0 297 fi 298 299 for file in "$@"; do 300 if [ ! -e "$file" ]; then 301 echo "$PROGRAM: $file does not exist" 302 continue 303 fi 304 if [ ! -s "$file" ]; then 305 echo "Ignore empty file $file" 306 continue 307 fi 308 submit_file "$file" 309 done
