Ejemplo n.º 1
0
def whale():
    if request.method == "POST":
        name = request.form["name"]
        if len(name) > 10: 
            return make_response("Name to long. Whales can only understand names up to 10 chars", 400)
        image_num = request.form["image_num"]
        weight = request.form["weight"]
        whale = Whale(name, image_num, weight)
        if whale.__dict__ == EASTER_WHALE:
            return make_response(flag.get_flag(), 200)
        return make_response(render_template("whale.html.jinja", w=whale, active="whale"), 200)
    return make_response(render_template("whale_builder.html.jinja", active="whale"), 200)
Ejemplo n.º 2
0
Archivo: rsa1.py Proyecto: comahax/ctf
def main():
    verify()
    usage = """
 **       **          **                                **********         
/**      /**         /**                               /////**///          
/**   *  /**  *****  /**  *****   ******  **********       /**      ****** 
/**  *** /** **///** /** **///** **////**//**//**//**      /**     **////**
/** **/**/**/******* /**/**  // /**   /** /** /** /**      /**    /**   /**
/**** //****/**////  /**/**   **/**   /** /** /** /**      /**    /**   /**
/**/   ///**//****** ***//***** //******  *** /** /**      /**    //****** 
//       //  ////// ///  /////   //////  ///  //  //       //      //////  

 **      **   ******  ********** ********   *******    ********     **    
/**     /**  **////**/////**/// /**/////   /**////**  **//////     ****   
/**     /** **    //     /**    /**        /**   /** /**          **//**  
/**********/**           /**    /*******   /*******  /*********  **  //** 
/**//////**/**           /**    /**////    /**///**  ////////** **********
/**     /**//**    **    /**    /**        /**  //**        /**/**//////**
/**     /** //******     /**    /**        /**   //** ******** /**     /**
//      //   //////      //     //         //     // ////////  //      // 

   ********                               
  **//////**                              
 **      //   ******   **********   ***** 
/**          //////** //**//**//** **///**
/**    *****  *******  /** /** /**/*******
//**  ////** **////**  /** /** /**/**//// 
 //******** //******** *** /** /**//******
  ////////   //////// ///  //  //  ////// 
	"""
    print usage
    print "This is a RSA Decryption System"
    print "Please enter Your team token: "
    token = raw_input()
    try:
        flag = get_flag(token)
        assert len(flag) == 32
    except:
        print "Token error!"
        m_exit(-1)

    p = getPrime(2048)
    q = getPrime(2048)
    n = p * q
    e, d = get_ed(p, q)
    print "n: ", hex(n)
    print "e: ", hex(e)

    flag = bytes_to_long(flag)
    enc_flag = pow(flag, e, n)
    print "Your flag is: ", hex(enc_flag)
Ejemplo n.º 3
0
def main():
	verify()
	usage = """
 **       **          **                                **********         
/**      /**         /**                               /////**///          
/**   *  /**  *****  /**  *****   ******  **********       /**      ****** 
/**  *** /** **///** /** **///** **////**//**//**//**      /**     **////**
/** **/**/**/******* /**/**  // /**   /** /** /** /**      /**    /**   /**
/**** //****/**////  /**/**   **/**   /** /** /** /**      /**    /**   /**
/**/   ///**//****** ***//***** //******  *** /** /**      /**    //****** 
//       //  ////// ///  /////   //////  ///  //  //       //      //////  

 **      **   ******  ********** ********   *******    ********     **    
/**     /**  **////**/////**/// /**/////   /**////**  **//////     ****   
/**     /** **    //     /**    /**        /**   /** /**          **//**  
/**********/**           /**    /*******   /*******  /*********  **  //** 
/**//////**/**           /**    /**////    /**///**  ////////** **********
/**     /**//**    **    /**    /**        /**  //**        /**/**//////**
/**     /** //******     /**    /**        /**   //** ******** /**     /**
//      //   //////      //     //         //     // ////////  //      // 

   ********                               
  **//////**                              
 **      //   ******   **********   ***** 
/**          //////** //**//**//** **///**
/**    *****  *******  /** /** /**/*******
//**  ////** **////**  /** /** /**/**//// 
 //******** //******** *** /** /**//******
  ////////   //////// ///  //  //  ////// 
	"""
	print usage
	print "This is a RSA Decryption System"
	print "Please enter Your team token: "
	token = raw_input()
	try:
		flag = get_flag(token)
		assert len(flag) == 38
	except:
		print "Token error!"
		m_exit(-1)
		
	p=getPrime(2048)
	q=getPrime(2048)
	n = p * q
	e, d = get_ed(p, q)
	print "n: ", hex(n)
	print "e: ", hex(e)

	flag = bytes_to_long(flag)
	enc_flag = pow(flag, e, n)
	print "Your flag is: ", hex(enc_flag)
Ejemplo n.º 4
0
def main():
	verify()
	usage = """
01010111 01100101 01101100 01100011 01101111 01101101  
01110100 01101111 00110010 00110000 00110001 00110110 
01001000 01000011 01010100 01000110 01010010 01010011 01000001 
01000100 01100101 01100011 01101111 01100100 01100101 
01010011 01111001 01110011 01110100 01100101 01101101 
	"""
	print usage
	print "This is a RSA Decryption System"
	print "Please enter Your team token: "
	try:
		token = raw_input()
		flag = get_flag(token)
		assert len(flag) == 38
	except:
		print "Token error!"
		m_exit(-1)

	spub, spriv = get_pkey()
	# Generation p, q
	p, q = GetPrimes(spub, spriv)
	n = p * q
	phi_n = (p-1)*(q-1)
	d = invmod(e, phi_n)
	while True:
		e2 = random.randint(0x1000, 0x10000)
		if gcd(e2, phi_n) == 1:
			break

	print "In this Game, Your public key:"
	print "n: ", hex(n)
	print "e: ", hex(e)
	print "e2: ", hex(e2)
	flag = bytes_to_long(flag)
	enc_flag = pow(flag, e2, n)
	print "Your flag is: ", hex(enc_flag)
	print "============Start Games============"
	print "Please enter your cipher: "
	while True:
		s = raw_input()
		try:
			c = int(s)
		except:
			m_exit(-1)
		m = pow(c, d, n)
		print "Your Plaintext is: ", hex(m)
		time.sleep(1)
Ejemplo n.º 5
0
def main():
    verify()
    usage = """
01010111 01100101 01101100 01100011 01101111 01101101  
01110100 01101111 00110010 00110000 00110001 00110110 
01001000 01000011 01010100 01000110 01010010 01010011 01000001 
01000100 01100101 01100011 01101111 01100100 01100101 
01010011 01111001 01110011 01110100 01100101 01101101 
	"""
    print usage
    print "This is a RSA Decryption System"
    print "Please enter Your team token: "
    try:
        token = raw_input()
        flag = get_flag(token)
        assert len(flag) == 38
    except:
        print "Token error!"
        m_exit(-1)

    spub, spriv = get_pkey()
    # Generation p, q
    p, q = GetPrimes(spub, spriv)
    n = p * q
    phi_n = (p - 1) * (q - 1)
    d = invmod(e, phi_n)
    while True:
        e2 = random.randint(0x1000, 0x10000)
        if gcd(e2, phi_n) == 1:
            break

    print "In this Game, Your public key:"
    print "n: ", hex(n)
    print "e: ", hex(e)
    print "e2: ", hex(e2)
    flag = bytes_to_long(flag)
    enc_flag = pow(flag, e2, n)
    print "Your flag is: ", hex(enc_flag)
    print "============Start Games============"
    print "Please enter your cipher: "
    while True:
        s = raw_input()
        try:
            c = int(s)
        except:
            m_exit(-1)
        m = pow(c, d, n)
        print "Your Plaintext is: ", hex(m)
        time.sleep(1)
Ejemplo n.º 6
0
def download_one(cc):
    image = get_flag(cc)
    show(cc)
    save_flag(image, cc.lower() + '.gif')
Ejemplo n.º 7
0
Archivo: rsa2.py Proyecto: comahax/ctf
def main():
	verify()
	usage = """
 **       **          **                                **********         
/**      /**         /**                               /////**///          
/**   *  /**  *****  /**  *****   ******  **********       /**      ****** 
/**  *** /** **///** /** **///** **////**//**//**//**      /**     **////**
/** **/**/**/******* /**/**  // /**   /** /** /** /**      /**    /**   /**
/**** //****/**////  /**/**   **/**   /** /** /** /**      /**    /**   /**
/**/   ///**//****** ***//***** //******  *** /** /**      /**    //****** 
//       //  ////// ///  /////   //////  ///  //  //       //      //////  

 **      **   ******  ********** ********   *******    ********     **    
/**     /**  **////**/////**/// /**/////   /**////**  **//////     ****   
/**     /** **    //     /**    /**        /**   /** /**          **//**  
/**********/**           /**    /*******   /*******  /*********  **  //** 
/**//////**/**           /**    /**////    /**///**  ////////** **********
/**     /**//**    **    /**    /**        /**  //**        /**/**//////**
/**     /** //******     /**    /**        /**   //** ******** /**     /**
//      //   //////      //     //         //     // ////////  //      // 

   ********                               
  **//////**                              
 **      //   ******   **********   ***** 
/**          //////** //**//**//** **///**
/**    *****  *******  /** /** /**/*******
//**  ////** **////**  /** /** /**/**//// 
 //******** //******** *** /** /**//******
  ////////   //////// ///  //  //  ////// 
	"""
	print usage
	print "This is a RSA Decryption System"
	print "Please enter Your team token: "
	try:
		token = raw_input()
		flag = get_flag(token)
		assert len(flag) == 32
	except:
		print "Token error!"
		m_exit(-1)

	p, q, e = gen_key()
	n = p * q
	phi_n = (p-1)*(q-1)
	d = invmod(e, phi_n)
	while True:
		e2 = random.randint(0x1000, 0x10000)
		if gcd(e2, phi_n) == 1:
			break
	print "n: ", hex(n)
	print "e: ", hex(e)
	print "e2: ", hex(e2)
	flag = bytes_to_long(flag)
	enc_flag = pow(flag, e2, n)
	print "Your flag is: ", hex(enc_flag)
	print "============Start Games============"
	print "Please enter your cipher: "
	while True:
		try:
			s = raw_input()
			c = int(s)
		except:
			m_exit(-1)
		m = pow(c, d, n)
		print "Your Plaintext is: ", hex(m)
		time.sleep(1)
Ejemplo n.º 8
0
def embed_region(data, region):
    country_data, alpha2 = get_country_data_fuzzy(data, region)
    if not country_data:
        raise commands.UserInputError('Country not found!')

    flag = country_code = '🚩'
    if country_data and country_data[-1] == 'All':
        flag = country_code = GLOBE
    if alpha2:
        flag = ':flag_{}:'.format(alpha2.lower())
        country_code = get_flag(alpha2.upper()) if alpha2 else flag
    flag_image = emutils.get_url(country_code)[0]

    wtotal_cases, _, wtotal_deaths = data[0][2:5]
    name, total_cases, new_cases, total_deaths, new_deaths, recovered, active_cases, critical, cases_per_1m, deaths_per_1m = country_data[
        1:11]

    recovered_percent = percent(recovered, total_cases, brackets=True)
    active_percent = percent(active_cases, total_cases, brackets=True)
    critical_percent = percent(critical, total_cases, brackets=True)

    wcases_percent = percent(total_cases, wtotal_cases)
    wdeaths_percent = percent(total_deaths, wtotal_deaths)
    deaths_percent = percent(total_deaths, total_cases)
    cases_percent = percent(cases_per_1m, 10**6)
    deaths_pop_percent = percent(deaths_per_1m, 10**6)

    is_world = country_data[-1] == 'All'
    wcases_percent = f'{GLOBE} {wcases_percent}' if wcases_percent and not is_world else ''
    wdeaths_percent = f'{GLOBE} {wdeaths_percent}' if wdeaths_percent and not is_world else ''
    deaths_percent = f':microbe: {deaths_percent}' if deaths_percent else ''
    cases_percent = f'{flag} {cases_percent}' if cases_percent else ''
    deaths_pop_percent = f'{flag} {deaths_pop_percent}' if deaths_pop_percent else ''

    total_cases, new_cases, total_deaths, new_deaths, recovered, active_cases, critical = map(
        comma, country_data[2:9])
    new_cases = plus(new_cases, hide_if_none=False)
    new_deaths = plus(new_deaths, hide_if_none=False)

    cases_percentages = '\n'.join(filter(None,
                                         [wcases_percent, cases_percent]))
    if cases_percentages: cases_percentages = '\n' + cases_percentages
    deaths_percentages = '\n'.join(
        filter(None, [wdeaths_percent, deaths_pop_percent, deaths_percent]))
    if deaths_percentages: deaths_percentages = '\n' + deaths_percentages

    explanation = '\n'.join(
        filter(None, (
            f'{GLOBE} % Global Cases' if flag != GLOBE else '',
            f'{flag} % Population' if flag in cases_percent +
            deaths_pop_percent else '',
            f':microbe: % Total Cases'
            if ':microbe:' in deaths_percent else '',
        )))

    title = f'Coronavirus cases for {name}'
    embed = colors.embed(title=title, url=URL, description=explanation) \
        .add_field(name=f'{TOTAL_CASES}', value=f'**{total_cases}** {new_cases}{cases_percentages}') \
        .add_field(name=f'{TOTAL_DEATHS}', value=f'**{total_deaths}** {new_deaths}{deaths_percentages}') \
        .add_field(name=f'{RECOVERED}', value=f'**{recovered}** {recovered_percent}', inline=False) \
        .add_field(name=f'Active Cases', value=f'**{active_cases}** {active_percent}') \
        .add_field(name=f'Critical', value=f'**{critical}** {critical_percent}') \
        .set_thumbnail(url=flag_image)
    embed.timestamp = datetime.now().astimezone()
    return embed
Ejemplo n.º 9
0
def main():
	verify()
	usage = """
 **       **          **                                **********         
/**      /**         /**                               /////**///          
/**   *  /**  *****  /**  *****   ******  **********       /**      ****** 
/**  *** /** **///** /** **///** **////**//**//**//**      /**     **////**
/** **/**/**/******* /**/**  // /**   /** /** /** /**      /**    /**   /**
/**** //****/**////  /**/**   **/**   /** /** /** /**      /**    /**   /**
/**/   ///**//****** ***//***** //******  *** /** /**      /**    //****** 
//       //  ////// ///  /////   //////  ///  //  //       //      //////  

 **      **   ******  ********** ********   *******    ********     **    
/**     /**  **////**/////**/// /**/////   /**////**  **//////     ****   
/**     /** **    //     /**    /**        /**   /** /**          **//**  
/**********/**           /**    /*******   /*******  /*********  **  //** 
/**//////**/**           /**    /**////    /**///**  ////////** **********
/**     /**//**    **    /**    /**        /**  //**        /**/**//////**
/**     /** //******     /**    /**        /**   //** ******** /**     /**
//      //   //////      //     //         //     // ////////  //      // 

   ********                               
  **//////**                              
 **      //   ******   **********   ***** 
/**          //////** //**//**//** **///**
/**    *****  *******  /** /** /**/*******
//**  ////** **////**  /** /** /**/**//// 
 //******** //******** *** /** /**//******
  ////////   //////// ///  //  //  ////// 
	"""
	print usage
	print "This is a RSA Decryption System"
	print "Please enter Your team token: "
	try:
		token = raw_input()
		flag = get_flag(token)
		assert len(flag) == 38
	except:
		print "Token error!"
		m_exit(-1)

	p, q, e = gen_key()
	n = p * q
	phi_n = (p-1)*(q-1)
	d = invmod(e, phi_n)
	while True:
		e2 = random.randint(0x1000, 0x10000)
		if gcd(e2, phi_n) == 1:
			break
	print "n: ", hex(n)
	print "e: ", hex(e)
	print "e2: ", hex(e2)
	flag = bytes_to_long(flag)
	enc_flag = pow(flag, e2, n)
	print "Your flag is: ", hex(enc_flag)
	print "============Start Games============"
	print "Please enter your cipher: "
	while True:
		try:
			s = raw_input()
			c = int(s)
		except:
			m_exit(-1)
		m = pow(c, d, n)
		print "Your Plaintext is: ", hex(m)
		time.sleep(1)