2014-12-31 4 views
0

짧은 이야기. 파이썬에서 코딩하는 데 몇 가지 문제가 있습니다.파이썬 - 와이파이 - reauth ap

는 MAC 주소를 스푸핑 및 AP에 새로운 시도 세션을 열 수있는 프로그램 작업, (이 교육으로 만 제공됩니다.)

프로그램은 무료로 1 시간 패스가 AP와 함께 작동합니다. 프로그램은 다음과 같이 작동합니다. wifi 어댑터를 종료합니다 .bat 스크립트를 실행합니다.이 스크립트는 mac 주소를 임의의 mac 주소로 변경합니다. 에서 Wi-Fi를 다시 켭니다. 브라우저를 열고 새 mac 주소로 로그인을 보냅니다. 은 1 시간마다 반복됩니다.

문제 : 주소를 변경하고 백업 할 수 있습니다. 하지만, var에 새 주소를 얻고 웹 브라우저를 통해 전달하여 자신을 다시 인증하십시오. 및 재판의 새 세션을여시겠습니까?

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' : '[email protected]' } 

    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'); 
    }); 
} 
}; 

내 질문은 :

내가 변수 APID 에서 AP의 MAC 주소를 얻는 방법 가 어떻게 그것이 해시를받을 수 있나요 MACID라는 변수에 새 MAC 주소를 얻는 방법 변수 hashid에 묻습니다. 어떻게 적절한 양식 데이터를 보내야합니까? 즉 .. 계획 ID.

+0

웹 재 인증 방법을 자세히 설명하지 않은 경우 웹 재 인증 방법을 알 수 없습니다. – Anzel

+0

방금 ​​ – daugherjo

답변

0

인증 서버에서 직접 인증해야합니다. 나는 인증과 재 인증 과정이 동일하다고 생각한다. requests 모듈을 사용하는 것이 좋습니다. 여기에 link이 있습니다. 이 같은

한번에 인증 코드 :

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

그것이 도움이되기를 바랍니다. :)

+0

링크를 이용해 주셔서 감사합니다. 도움이됩니다. 방금 내 질문을 업데이트했습니다. – daugherjo

+0

@daugherjo이 대답이 도움이된다면, 그냥 받아주십시오. 추가 질문이있는 경우 다른 사람이이 관련 답변과 혼동하지 않도록 다른 질문을하십시오. :) –