Script Console cryptography for HttpNtlmAuth requests.get Import Error

Post code, not pictures of code. It helps with searching via text. Please see Wiki - how to post code on this forum. You can edit your post by clicking the pencil icon on the bottom right.

Edit: Code for those searching:

Original
url = 'MY URL'
un = 'MY USERNAME'
do = 'MY DOMAIN'
pwd = 'MY PASSWORD'


# Import
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.NTCredentials;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.client.methods.HttpGet
import org.apache.http.util.EntityUtils


credProv	= org.apache.http.impl.client.BasicCredentialsProvider()	# Build credentials provider
ntCred		= org.apache.http.auth.NTCredentials(un, pwd, '', do)		# Build NT domain credentials
credProv.setCredentials(org.apache.http.auth.AuthScope.ANY, ntCred);	# Set credentials
bld 		= org.apache.http.impl.client.HttpClientBuilder.create()	# Create HttpClientBuilder
client		= bld.setDefaultCredentialsProvider(credProv).build()		# Build client with credential proxy

get 		= org.apache.http.Client.methods.HttpGet(url)	# Define http get
res			= client.execute(get)							# Execute get

# Result string
ress		= str(org.apache.http.util.EntityUtils.toString(res.getEntity(), 'UTF-8'))
Slimmed
from org.apache.http.auth import AuthScope, NTCredentials
from org.apache.http.impl.client import BasicCredentialsProvider, HttpClientBuilder
from org.apache.http.client.methods import HttpGet
from org.apache.http.util import EntityUtils

url = 'MY URL'
un = 'MY USERNAME'
do = 'MY DOMAIN'
pwd = 'MY PASSWORD'


credProv	= BasicCredentialsProvider()		# Build credentials provider
ntCred		= NTCredentials(un, pwd, '', do)	# Build NT domain credentials
credProv.setCredentials(AuthScope.ANY, ntCred);	# Set credentials

bld 		= HttpClientBuilder.create()							# Create HttpClientBuilder
client		= bld.setDefaultCredentialsProvider(credProv).build()	# Build client with credential proxy

get 		= HttpGet(url)			# Define http get
res			= client.execute(get)	# Execute get

# Result string
ress		= str(EntityUtils.toString(res.getEntity(), 'UTF-8'))
3 Likes