403Webshell
Server IP : 123.56.80.60  /  Your IP : 216.73.216.78
Web Server : Apache/2.4.54 (Win32) OpenSSL/1.1.1s PHP/7.4.33 mod_fcgid/2.3.10-dev
System : Windows NT iZhx3sob14hnz7Z 10.0 build 14393 (Windows Server 2016) i586
User : SYSTEM ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Program Files (x86)/Alibaba/Aegis/PythonLoaderTemp/third_party/win32/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Program Files (x86)/Alibaba/Aegis/PythonLoaderTemp/third_party/win32/scripts/rasutil.py
# A demo of using the RAS API from Python
import sys
import win32ras

# The error raised if we can not
class ConnectionError(Exception):
	pass
	
def Connect(rasEntryName, numRetries = 5):
	"""Make a connection to the specified RAS entry.
	
	Returns a tuple of (bool, handle) on success.
	- bool is 1 if a new connection was established, or 0 is a connection already existed.
	- handle is a RAS HANDLE that can be passed to Disconnect() to end the connection.
	
	Raises a ConnectionError if the connection could not be established.
	"""
	assert numRetries > 0
	for info in win32ras.EnumConnections():
		if info[1].lower()==rasEntryName.lower():
			print "Already connected to", rasEntryName
			return 0, info[0]

	dial_params, have_pw = win32ras.GetEntryDialParams(None, rasEntryName)
	if not have_pw:
		print "Error: The password is not saved for this connection"
		print "Please connect manually selecting the 'save password' option and try again"
		sys.exit(1)

	print "Connecting to", rasEntryName, "..."
	retryCount = numRetries
	while retryCount > 0:
		rasHandle, errCode = win32ras.Dial(None, None, dial_params, None)
		if win32ras.IsHandleValid(rasHandle):
			bValid = 1
			break
		print "Retrying..."
		win32api.Sleep(5000)
		retryCount = retryCount - 1
	
	if errCode:
		raise ConnectionError(errCode, win32ras.GetErrorString(errCode))
	return 1, rasHandle

def Disconnect(handle):
	if type(handle)==type(''): # have they passed a connection name?
		for info in win32ras.EnumConnections():
			if info[1].lower()==handle.lower():
				handle = info[0]
				break
		else:
			raise ConnectionError(0, "Not connected to entry '%s'" % handle)

	win32ras.HangUp(handle)

usage="""rasutil.py - Utilities for using RAS

Usage:
  rasutil [-r retryCount] [-c rasname] [-d rasname]
  
  -r retryCount - Number of times to retry the RAS connection
  -c rasname - Connect to the phonebook entry specified by rasname
  -d rasname - Disconnect from the phonebook entry specified by rasname
"""

def Usage(why):
	print why
	print usage
	sys.exit(1)
	
if __name__=='__main__':
	import getopt
	try:
		opts, args = getopt.getopt(sys.argv[1:], "r:c:d:")
	except getopt.error, why:
		Usage(why)
	retries = 5
	if len(args) != 0:
		Usage("Invalid argument")

	for opt, val in opts:
		if opt=='-c':
			Connect(val, retries)
		if opt=='-d':
			Disconnect(val)
		if opt=='-r':
			retries = int(val)

Youez - 2016 - github.com/yon3zu
LinuXploit