Beispiel #1
0
def test():
    str = b'jz4Vxns'

    expect = base64.b64encode(str)
    actual = mybase64.b64encode(str)
    print('expect: ', expect)
    print('actual: ', actual)
    print(expect == actual)
Beispiel #2
0
def compare():
    rstr = randomString()
    exp = base64.b64encode(rstr)
    act = mybase64.b64encode(rstr)
    if (exp != act):
        print(rstr)
        print(exp)
        print(act)
        raise ValueError
def startfunc(IP,key,password):
    key = key
    password = password

    token = mybase64.b64encode(key + ":" + password)
    print token
    headers = {'Authorization': "Basic " + token, 'Accept': 'application/json'}
    url = "https://api.xforce.ibmcloud.com:443"
    scanurl = IP
    apiurl = url + "/ipr/"
    all_json = send_request(apiurl, scanurl, headers)
    apiurl = url + "/ipr/malware/"
    send_request(apiurl, scanurl, headers)
    apiurl = url + "/ipr/history/"
    historic = send_request(apiurl, scanurl, headers)
    print(historic)
    already_categorized=[]                      #Declarations
    key_count = 0
    category_count = 0
    review_count = len(historic['history'])
    all_categories = ""

    for key in historic['history']:            #For every entry in the json output 
        for entry in key["categoryDescriptions"]:      #For every categorization within that entrys "categoryDescriptions
            if(entry in already_categorized):               #If this categorization has already been reported, don't report it again
                continue
            else:       #Since we already have this IP in our DB,
            
            
                if category_count == 0:
                    all_categories = str(entry)
                    category_count += 1
                else:
                    all_categories = all_categories + " , " + str(entry)
                    category_count += 1 


                already_categorized.append(entry)   #Add the category to the list of already printed categories so we don't repeat

    toreturn = {'categories': all_categories,'geolocation':all_json["geo"]["country"],'score': str(get_current_info(2,review_count,scanurl,all_json))}
    return toreturn
Beispiel #4
0
def encode2():
    rstr = randomString()
    mybase64.b64encode(rstr)
Beispiel #5
0
from mybase64 import b64encode

hex_str = ("49276d206b696c6c696e6720796f7572"
           "20627261696e206c696b65206120706f"
           "69736f6e6f7573206d757368726f6f6d")
bytes_ = bytes.fromhex(hex_str)

encoded = b64encode(bytes_)
print(encoded)

expected = "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t"
assert (encoded == expected)
Beispiel #6
0
from mybase64 import b64encode


hex_str = ("49276d206b696c6c696e6720796f7572"
           "20627261696e206c696b65206120706f"
           "69736f6e6f7573206d757368726f6f6d")
bytes_ = bytes.fromhex(hex_str)

encoded = b64encode(bytes_)
print(encoded)

expected = "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t"
assert(encoded == expected)