Python - wifi - reauth ap

时间:2014-12-31 04:41:04

标签: python web wifi

长话短说。 在python中遇到一些编码问题。

致力于欺骗mac地址的程序并在ap上打开新的试用会话, (这只适用于教育。)

该程序适用于ap,可免费通过1小时。 该程序的工作方式如下: 关闭wifi适配器 运行.bat脚本,将mac地址更改为随机mac地址。 重新打开wifi。 打开浏览器并使用新的mac地址发送登录。 每1小时重复一次。

问题: 我可以关闭dowm,更改地址并重新启动。但, 如何在var中获取新地址并通过Web浏览器传递它以重新验证自己。 并开启一个新的审判会议?

import urllib.parse
import urllib.request
import os
import time

def main():
    wifidown()
    changemac()
    wifiup()
    reauth()
    time.sleep(3600)

def wifidown():
    os.system("wmic path win32_networkadapter where index=7 call disable")

def changemac():
    os.system("C:\Users\username\somewhere\theprogram\theprogram.bat")

def wifiup():
    os.system("wmic path win32_networkadapter where index=7 call enable")

def reauth():
    url = 'https://server.name.com/anothername/?client-mac=mymacaddress&ap-mac=addressofap&hash=somehasvaluethatpassesthrough'
    values = {'plan' : 'trial',
              'zip code' : '12345',
              'e mail' : 'anemail@someemail' }

    data = urllib.parse.urlencode(values)
    data = data.encode('utf-8')
    req = urllib.request.Request(url, data)
    response = urllib.request.urlopen(req)
    the_page = response.read()

while True:
    main()

谢谢。

更新**

是的,这有帮助。我试图这样做。

macid = "01:02:03:04:05:06"
mac = "?client-mac=" + macid
apid = "01:02:03:04:05:06"
ap = "&ap-mac=" + apid
hashid = "8JTsXjOC7jcCppExAqbsBmFF4kNMePA6wgrMaMI6MLDUO6bZsc8tgQMfEfGY%2Bp9aLEdXfTZCapb%2B93DotAFLlQ%3D%3D"
thehash = "&hash=" + hashid
url = 'https://the.ap.server.website/' + mac + ap + thehash

def main():
    wifidown()
    changemac()
    wifiup()
    urlfunction()
    time.sleep(3600)

def wifidown():
    os.system("wmic path win32_networkadapter where index=7 call disable")

def changemac():
    os.system("C:\Users\esc_fn\Desktop\macchanger\macchange.bat")

def urlfunction():
    webbrowser.open_new(url)

def wifiup():
    os.system("wmic path win32_networkadapter where index=7 call enable")

while True:
    main()

ap使用名为purchase.js的脚本来获取表单数据并发送它。 代码就是。

var pdate = new Date();
var offerlink = basepath + 'terms/';

$(document).ready(function(){
// Hide Sponsored Access form
$('#complimentary_spn').hide();
$('#xsubad').hide();

$('a#inline').fancybox({
    hideOnContentClick: false,
    showCloseButton: false,
    margin: 0,
    padding: 0
});

$('a.iframe').fancybox({
    hideOnContentClick: false,
    showCloseButton: false,
    scrolling: 'no',
    margin: 0,
    padding: 0,
    height: 510
});

$('#triggerComplete').fancybox({
    hideOnContentClick: false,
    showCloseButton: false,
    margin: 0,
    padding: 0
});

$('#rateplanid').change(function(){
    // Clear all errors
    clear_all_errors('#messageBox');

    var planid = $(this).val();
    if (planid > 0)
    {
        $('#complimentary_spn').fadeOut('fast');
        $('#xsubad').fadeOut('fast');
        $('#paid').fadeIn('fast');

        // Set offer and restrictions link
        $('#offerlink').find('.pop').attr('href', offerlink+'ppu');
    }
    else
    {
        $('#paid').fadeOut('fast');
        $('#complimentary_spn').fadeIn('fast');

        if ($.inArray(planid, do_reg) < 0)
            $('#xsubad').fadeIn('fast');

        // Set offer and restrictions link
        $('#offerlink').find('.pop').attr('href', offerlink+planid);
    }

    // Set plan cookie to expire in 10 minutes
    pdate.setTime(pdate.getTime() + (10 * 60 * 1000));
    setCookie('planid', planid, pdate, '/', '', '');

    // Reset required fields
    set_required_fields();

    // Disable submit buttons
    check_enable_submit();

    $(this).blur();
});

// Set default plan
if (getCookie('planid'))
    $('#rateplanid').val(getCookie('planid'));
else if (planid)
    $('#rateplanid').val(planid);

// Trigger change to set required fields
$('#rateplanid').trigger('change');

$("#pwreset").click(function(){
    $.post(
        basepath + 'ajax/resetpw',
        {
            username: $('#resetuser').val()
        },
        function(data) {
            if (data == '')
            {
                $.fancybox.close();
                return;
            }

            set_error('resetuser', data);
        }
    );
});

$('input, select').not('#resetuser').change(function(){
    $.post(
        actionurl+'/validate',
        $('#purchaseForm').serialize() + '&key=' + $(this).attr('name'),
        function(data) { validate_done(data) }
    );
});

$('input.submitOrderButton, input.startSessionButton').click(function(){
    if ($(this).hasClass('opaque'))
        return;

    $.post(
        actionurl+'/validate',
        $('#purchaseForm').serialize(),
        function(data) { validate_done(data) }
    );
});
});

// Override validation error
validate_error = function(json_data)
{
//console.info('purchase.validate_error');

try
{
    if (json_data.errors.nobilling)
    {
        // Pop payment form
        $('.iframe').click()
        return;
    }

    $.each(json_data.errors, function(key, msg) {
        set_error(key, msg);
    });

    window.location.hash = '#messageBox';
}
catch (e)
{
    console.error('purchase.validate_error - %s - %s', e.name, e.message);
}
};

// Override validation success
validate_success = function(json_data)
{
//console.info('purchase.validate_success');

try
{
    var planid = $('#rateplanid').val();

    // For Sponsored Access, perform login
    if ($.inArray(planid, ['spn']) >= 0)
    {
        do_login();
        return;
    }

    // For paid access, pop confirmation screen
    $('#completePopup').html(json_data.data.pophtml);
    $('#triggerComplete').click();

    // Track with Omniture
    var s = s_gi('comcastwificaptiveportalprod');
    s.tl(this,'o','Payment Confirmation Desktop Page');

    return;
}
catch (e)
{
    console.error('purchase.validate_success - %s - %s', e.name, e.message);
}
};

var confirmed = function()
{
$.fancybox.close();
do_login();
};

 var set_required_fields = function()
 {
  //console.info('purchase.set_required_fields');

// Clear required fields
$('.required').removeClass('required');

var planid = $('#rateplanid').val();
if (planid > 0)
{
    // Set required fields
    $('input#username, input#password, input#password1, input#password2').addClass('required');
    $('input#firstname, input#lastname, input#email').addClass('required');
    $('#paymentFormInputs1, #paymentFormInputs2').find(':input').each(function() {
          $(this).not('#storeinfo').addClass('required');
    });
}
else
{
    // Set required fields
    $('#complimentary_'+planid).find(':input').each(function() {
      $(this).addClass('required');
    });
}
};

我的问题是:

如何在名为macid的变量中获取新的mac地址 如何在变量apid中获取ap mac地址 我如何获得它要求的哈希并将其放入变量hashid中 如何通过发送相应的表单数据。即..计划ID。

1 个答案:

答案 0 :(得分:0)

您只需要在身份验证服务器上验证自己吗?我认为身份验证和重新身份验证的过程是一样的。建议使用requests模块。以下是link

尝试这样的身份验证代码:

>>> from requests.auth import HTTPBasicAuth
>>> requests.get('https://api.github.com/user', auth=HTTPBasicAuth('user', 'pass'))
<Response [200]>

希望它有所帮助。 :)