コード例 #1
0
def encode(state):
    d = state.data()
    chk = checksum(d)
    d.extend(chk)

    out = encodeData(d)
    return out
コード例 #2
0
ファイル: ip.py プロジェクト: Gowabby/Nscan
 def pack(self):
     ip_header = struct.pack("!BBHHHBBH4s4s",
                 self.ver_ihl,
                 self.tos,
                 self.length,
                 self.id,
                 self.flags_offset,
                 self.ttl,
                 self.protocol,
                 0, # checksum should be 0
                 self.src,
                 self.dst)
     self.checksum = checksum(ip_header)
     ip_header = struct.pack("!BBHHHBBH4s4s",
                 self.ver_ihl,
                 self.tos,
                 self.length,
                 self.id,
                 self.flags_offset,
                 self.ttl,
                 self.protocol,
                 socket.htons(self.checksum),
                 self.src,
                 self.dst)
     return ip_header
コード例 #3
0
ファイル: udp.py プロジェクト: Gowabby/Nscan
 def pack(self, src, dst, proto=socket.IPPROTO_UDP):
     length = self.length + len(self.payload)
     pseudo_header = struct.pack('!4s4sBBH', src, dst, 0, 
         proto, length)
     self.checksum = checksum(pseudo_header)
     packet = struct.pack('!HHHH',
         self.srcp, self.dstp, length, 0)
     return packet
コード例 #4
0
ファイル: ip.py プロジェクト: wuzhixiang/DDos_Attack_Progran
 def pack(self):
     ip_header = struct.pack(
         "!BBHHHBBH4s4s",
         self.ver_ihl,
         self.tos,
         self.length,
         self.id,
         self.flags_offset,
         self.ttl,
         self.protocol,
         0,  # checksum should be 0
         self.src,
         self.dst)
     self.checksum = checksum(ip_header)
     ip_header = struct.pack("!BBHHHBBH4s4s", self.ver_ihl, self.tos,
                             self.length, self.id, self.flags_offset,
                             self.ttl, self.protocol,
                             socket.htons(self.checksum), self.src,
                             self.dst)
     return ip_header
コード例 #5
0
 def pack(self, src, dst):
     data_offset = (self.offset << 4) + 0
     flags = self.fin + (self.syn << 1) + (self.rst << 2) + (self.psh << 3) + (self.ack << 4) + (self.urg << 5)
     tcp_header = struct.pack('!HHLLBBHHH', 
                  self.srcp, 
                  self.dstp, 
                  self.seqn, 
                  self.ackn, 
                  data_offset, 
                  flags,  
                  self.window,
                  self.checksum,
                  self.urgp)
     #pseudo header fields
     #source_ip = src
     #destination_ip = dst
     reserved = 0
     protocol = IPPROTO_TCP
     total_length = len(tcp_header) + len(self.payload)
     # Pseudo header
     psh = struct.pack("!4s4sBBH",
           src,
           dst,
           reserved,
           protocol,
           total_length)
     psh = psh + tcp_header + self.payload
     tcp_checksum = checksum(psh)
     tcp_header = struct.pack("!HHLLBBH",
               self.srcp,
               self.dstp,
               self.seqn,
               self.ackn,
               data_offset,
               flags,
               self.window)
     tcp_header+= struct.pack('H', tcp_checksum) + struct.pack('!H', self.urgp)
     return tcp_header
コード例 #6
0
all_filenames = sys.argv[1:]

parser = OptionParser(usage="Usage: %prog [OPTION] [FILE]...")
parser.add_option('-v',
                  '--verbose',
                  dest='verbose',
                  default=False,
                  action='store_true',
                  help='Turn on verbose output')
options, args = parser.parse_args()

flickr = authenticate_to_flickr()

for filename in args:
    md5sum = checksum(filename, "md5")
    if options.verbose:
        print "filename was: " + filename
        print " with md5sum: " + md5sum
    existing = search_for_checksum(flickr, md5=md5sum)
    if 1 == len(existing):
        if options.verbose:
            print "  ... already uploaded"
            print short_url(existing[0].attrib['id'])
    elif len(existing) > 1:
        if options.verbose:
            print "  ... multiple copies uploaded"
    else:
        if options.verbose:
            print "  ... not uploaded"
        else:
コード例 #7
0
ファイル: udp.py プロジェクト: Soldie/Nscan-scanner-ip
 def pack(self, src, dst, proto=socket.IPPROTO_UDP):
     length = self.length + len(self.payload)
     pseudo_header = struct.pack('!4s4sBBH', src, dst, 0, proto, length)
     self.checksum = checksum(pseudo_header)
     packet = struct.pack('!HHHH', self.srcp, self.dstp, length, 0)
     return packet
コード例 #8
0
from flickr_common import authenticate_to_flickr
from flickr_checksum_lib import search_for_checksum
from flickrapi.shorturl import url as short_url

all_filenames = sys.argv[1:]

parser = OptionParser(usage="Usage: %prog [OPTION] [FILE]...")
parser.add_option('-v', '--verbose', dest='verbose', default=False,
                  action='store_true',
                  help='Turn on verbose output')
options, args = parser.parse_args()

flickr = authenticate_to_flickr()

for filename in args:
    md5sum = checksum(filename, "md5")
    if options.verbose:
        print "filename was: "+filename
        print " with md5sum: "+md5sum
    existing = search_for_checksum(flickr, md5=md5sum)
    if 1 == len(existing):
        if options.verbose:
            print "  ... already uploaded"
            print short_url(existing[0].attrib['id'])
    elif len(existing) > 1:
        if options.verbose:
            print "  ... multiple copies uploaded"
    else:
        if options.verbose:
            print "  ... not uploaded"
        else: