network card

X

Xaver Biton

hi,
there's a way to set up a network card and create a a network connection
with perl on win32. It woul be great if you couls mane me an example.

Thks.

Xavre
 
X

Xaver Biton

there's a way to set up a network card and create a a network connection
with perl on win32. It woul be great if you couls mane me an example.

I see some Programms, that by installing it, they create a network
connection, for the current user, how they do that. I ve tried with
Win32::IPHelper and with Win32::IPConfig, but a can see only the current
configuration, the question is how can I create a totally new connection?

Thks.

Xaver
 
B

Bill

Xaver said:
I see some Programms, that by installing it, they create a network
connection, for the current user, how they do that. I ve tried with
Win32::IPHelper and with Win32::IPConfig, but a can see only the current
configuration, the question is how can I create a totally new connection?

Well...
The problem with your question is that the term 'network connection' can
trefer to many things, many but not all of which can be done with Perl.
Can you explain what you want to do with the network connection once you
have it? That might allow people here to better understand what kind on
'connection' you mean...
 
X

Xaver Biton

trefer to many things, many but not all of which can be done with Perl.
Can you explain what you want to do with the network connection once you
have it? That might allow people here to better understand what kind on
'connection' you mean...

Ok, sorry if was unclear. In windows, wenn you go in dial-up and network
connection, you can click on new connection and create it manually with the
wizard, what I want to do is actually automating the whole process with a
perl script. Now, if a connection exist I can manipulate it with IPHeper and
IPConfig, but if does't exist, how do I create a new one?

many thks.

Xaver
 
X

Xaver Biton

Bill said:
Well...
The problem with your question is that the term 'network connection' can
trefer to many things, many but not all of which can be done with Perl.
Can you explain what you want to do with the network connection once you
have it? That might allow people here to better understand what kind on
'connection' you mean...

Ok, sorry if was unclear. In windows, wenn you go in dial-up and network
connection, you can click on new connection and create it manually with the
wizard, what I want to do is actually automating the whole process with a
perl script. Now, if a connection exist I can manipulate it with IPHeper and
IPConfig module, but if does't exist, how do I create a new one?

many thks.

Xaver
 
J

Joe Smith

Xaver said:
Ok, sorry if was unclear. In windows, wenn you go in dial-up and network
connection, you can click on new connection and create it manually with the
wizard, what I want to do is actually automating the whole process with a
perl script. Now, if a connection exist I can manipulate it with IPHeper and
IPConfig, but if does't exist, how do I create a new one?

Are you trying to set up a network connection that will use a dial-up
ISP of your own choosing without the user being aware of it?

That's a technique used by porn sites to force unwitting users to
rack up expensive long-distance telephone charges.
 
B

Bill

Ok, sorry if was unclear. In windows, wenn you go in dial-up and network
connection, you can click on new connection and create it manually with the
wizard, what I want to do is actually automating the whole process with a
perl script. Now, if a connection exist I can manipulate it with IPHeper
and
IPConfig module, but if does't exist, how do I create a new one?

Win32::RASE, eg ppm install Win32::RASE or so forth

HTH
 
X

Xaver Biton

Joe said:
Are you trying to set up a network connection that will use a dial-up
ISP of your own choosing without the user being aware of it?

That's a technique used by porn sites to force unwitting users to
rack up expensive long-distance telephone charges.

Dear Mr. Smith,

you don't have to thing, that everyone that want to automate a network
connection, he want to do it to swindle the people. I want to do it for
a ISP. the script will be incorporate in the istallation Programm.

I'm ready to collaborate making a perl programm to watch out the
connections, and protect the internet user from such program, and make
it open source.

Regards.

Xaver Biton
 
X

Xaver Biton

Bill said:
Win32::RASE, eg ppm install Win32::RASE or so forth

This module is not on ActiveState, its only on CPAN. I Downloaded the
Module from CPAN. I Raad the README file, which says, that should work
also if only copied in @INC. I've done it but wenn I run an example
script I recieve the following error:

Win32::RASE::TAPIlineGetTranslateCaps() called too early to check
prototype at c:/Perl/lib/RASE.pm line 266.
Could not open C:\ window
BEGIN failed--compilation aborted at examples.pl line 500.

I was asking myself, if there's a possibility to use the Win32::API for
creating a dial-up connection.

Xaver



#!/usr/bin/perl -w
#
# This is an exit-separated collection of tests to Win32::RASE module
# move one of the tests on top to run
#
#

$|=1;

use RASE;


#----------- printing device properties ---------------
RasPrintEntryProperties("MY_ENTRY");
exit;
#----------- printing device properties ---------------
$modem_name = (RasEnumDevicesByType("modem"))[0] or
die "No one \"$type\" device were found\n";
$CC = Win32::RASE::GetDefaultCommConfig($modem_name);
print length $CC;
exit;

#----------- test of RasSetEntryProperties ---------------
# please try also with "vpn" if you have MS Virtual Private Network installed
$entry = "MY_ENTRY";
$type = "modem";

$modem_name = (RasEnumDevicesByType($type))[0] or
die "No one \"$type\" device were found\n";

print "First device of type \"$type\": \"$modem_name\"\n\n";
RasSetEntryProperties({
name => $entry,
CountryCode => "7",
AreaCode => "812",
LocalPhoneNumber => "325-52-95",
DeviceName => $modem_name,
newFlags => "+KeepOldFlags -UseCountryAndAreaCodes",
})
or die Win32::RASE::FormatMessage;

print "Entry \"$entry\" changed successfully\n";
exit;

#----------- test of RasCreateEntry ---------------
# please try also with "vpn"
$new_entry = "MY_ENTRY";
$type = "modem";

$modem_name = (RasEnumDevicesByType($type))[0] or
die "No one \"$type\" device were found\n";

print "First device of type \"$type\": \"$modem_name\"\n\n";

RasCreateEntry({
name => $new_entry,
CountryCode => "250",
AreaCode => "012",
LocalPhoneNumber => "325-52-96",
DeviceName => $modem_name,
NetProtocols => ["Ip"],
FramingProtocol => "PPP",
ipaddrDns => "195.190.100.28",
ipaddrDnsAlt => "195.190.100.12",
newFlags => "UseCountryAndAreaCodes SpecificNameServers
ModemLights NetworkLogon RemoteDefaultGateway",
})
or die Win32::RASE::FormatMessage;

print "Entry \"$new_entry\" created successfully\n";
exit;



#=========================


#----------- test of RasDial ---------------
print "\nI'm dialing via the first RAS entry: $first_RAS_entry\n\n";

($UserName, $Password) = RasGetUserPwd($first_RAS_entry)
or die Win32::RASE::FormatMessage;

print "UserName:";
!$UserName ? chomp($UserName=<>) : print "$UserName\n";

print "Password:";
!$Password ? chomp($Password=<>) : print "$Password\n";


$hrasconn = RasDial($first_RAS_entry, undef , $UserName, $Password)
or die Win32::RASE::FormatMessage;

#($err, $status) = RasDial("CLICK", "DP 110-6511" , $UserName, $Password,undef,undef)
# or die Win32::RASE::FormatMessage;

print "Connected, \$hrasconn=$hrasconn\n";
exit;

#----------- test of RasGetProjectionInfo ---------------
unless ( $hrasconn = (RasEnumConnections())[1] ) {
print "Dialing sequence not started\n";

} elsif ( ($ip, $server_ip) = RasGetProjectionInfo( $hrasconn ) ) {
print "LOCAL:$ip SERVER:$server_ip\n";

} elsif ( Win32::RASE::GetLastError == 731 ) {
print "Protocol not configured yet\n";

} else {
die Win32::RASE::FormatMessage;
}
exit;

#----------- test of HangUp ---------------
if ( HangUp() ) {
print "Disconnected successfully.\n";
} else {
print "Some connections might be still active.\n";
}

exit;

#----------- test of RasHangUp ---------------
$hrasconn = (RasEnumConnections())[1];
if ( RasHangUp($hrasconn, 2) ) {
print "Connection was terminated successfully.\n";
} elsif ( !Win32::RASE::GetLastError ) {
print "Timeout. Connection is still active.\n";
} else {
# we don't have to die here
warn Win32::RASE::FormatMessage, "\n";
}
exit;


#----------- test of RasGetConnectStatus ---------------
# start connecton by some other tool (DUN for exmple),
# run this, see how it connects and then hang up - also by yourself

eval "use Time::HiRes qw(sleep)";
$hrasconn = (RasEnumConnections())[1];
$old_status = -1;

while ( ($status, $status_text) = RasGetConnectStatus($hrasconn) ) {
if ($status != $old_status) {
print "$status: $status_text\n";
$old_status = $status;
}
sleep ($@ ? 1 : 0.01);
}
# error 6 - Invalid handle
($err = Win32::RASE::GetLastError) != 6 and die Win32::RASE::FormatMessage($err);
exit;


#----------- test of RasEnumConnections ---------------
if (%conn = RasEnumConnections()) {
print map "$_: hrasconn=$conn{$_}\n", keys %conn;

} else {
print "No active connections\n";
}
exit;

#----------- printing device properties ---------------
RasPrintEntryDevProperties($first_RAS_entry);
exit;


#----------- test of RasChangePhoneNumber ---------------
# be carefull!!! this will change the phonenumber
# in your RAS entry

$entry = "<put here>";

IsEntry($entry) or die "Entry \"$entry\" not found.\n";

print "RAS entry: $entry\n";

RasChangePhoneNumber($entry, "1-(212)-211-5555")
or die Win32::RASE::FormatMessage;

print "Changed successfully\n\n";
RasPrintEntryProperties($entry);
exit;

#----------- test of RasCreateEntry ---------------
# please try also with "vpn"
$new_entry = "<put here>";
$type = "modem";

$modem_name = (RasEnumDevicesByType($type))[0] or
die "No one \"$type\" device were found\n";

print "First device of type \"$type\": \"$modem_name\"\n\n";

RasCreateEntry({
name => $new_entry,
CountryCode => "250",
AreaCode => "012",
LocalPhoneNumber => "325-52-96",
DeviceName => $modem_name,
NetProtocols => ["Ip"],
FramingProtocol => "PPP",
ipaddrDns => "195.190.100.28",
ipaddrDnsAlt => "195.190.100.12",
newFlags => "UseCountryAndAreaCodes SpecificNameServers
ModemLights NetworkLogon RemoteDefaultGateway",
})
or die Win32::RASE::FormatMessage;

print "Entry \"$new_entry\" created successfully\n";
exit;

#----------- test of RasSetEntryProperties ---------------
# please try also with "vpn"
$entry = "<put here>";
$type = "modem";

$modem_name = (RasEnumDevicesByType($type))[0] or
die "No one \"$type\" device were found\n";

print "First device of type \"$type\": \"$modem_name\"\n\n";
RasSetEntryProperties({
name => $entry,
CountryCode => "250",
AreaCode => "012",
LocalPhoneNumber => "325-52-95",
DeviceName => $modem_name,
newFlags => "+KeepOldFlags -UseCountryAndAreaCodes",
})
or die Win32::RASE::FormatMessage;

print "Entry \"$entry\" changed successfully\n";
exit;

#----------- printing entry properties ---------------
RasPrintEntryProperties($first_RAS_entry);
exit;

#----------- test of RasGetEntryProperties ---------------
print "First RAS entry: $first_RAS_entry\n";

$p = RasGetEntryProperties($first_RAS_entry)
or die Win32::RASE::FormatMessage;

print map "$_ => $p->{$_}\n",sort keys %$p;
exit;

#----------- test of RasRenameEntry ---------------
$entry_old = "<put here>";
$entry_new = "<put here>";

RasRenameEntry($entry_old, $entry_new)
or die Win32::RASE::FormatMessage;

print "Entry \"$entry_old\" successfully renamed to \"$entry_new\"\n";
exit;

#----------- test of RasDeleteEntry ---------------
# be carefull!!! this will remove your RAS entry

$entry = "<put here>";

RasDeleteEntry($entry)
or die Win32::RASE::FormatMessage;

print "Entry \"$entry\" was removed.\n";
exit;

#----------- test of RasCopyEntry ---------------
print "Existing entry: $first_RAS_entry\n";

RasCopyEntry($first_RAS_entry, $first_RAS_entry.".copy")
or die Win32::RASE::FormatMessage;

print "Entry \"$first_RAS_entry.copy\" created successfully\n";

exit;

#----------- test of RasEnumEntries ---------------
@entries = RasEnumEntries()
or die Win32::RASE::FormatMessage;
print "@entries\n";
exit;

#----------- test of IsEntry ---------------
$entry = "<put here>";

print (IsEntry($entry) ? "$entry exists" : "$entry does not exist");
exit;

#----------- test of RasSetEntryDialParams (adding the password) --------
# be carefull!!! this will change login/password
# in your RAS entry

$entry = "<put here>";
$UserName = "";
$Password = "";

IsEntry($entry) or die "Entry \"$entry\" not found.\n";

print "RAS entry: $entry\n";

RasSetEntryDialParams($entry, $UserName, $Password)
or die Win32::RASE::FormatMessage;

print "Changed successfully\n";
exit;

#----------- test of RasSetEntryDialParams (removing the password) --------
# be carefull!!! this will remove password of the specified user
# in your RAS entry

$entry = "<put here>";
$UserName = "<put here>";

IsEntry($entry) or die "Entry \"$entry\" not found.\n";

print "RAS entry: $entry\n";

RasSetEntryDialParams($entry, $UserName, "", undef, undef, 1)
or die Win32::RASE::FormatMessage;

print "Changed successfully\n";
exit;

#----------- test of RasGetUserPwd ---------------
print "First RAS entry: $first_RAS_entry\n";

($UserName, $Password) = RasGetUserPwd($first_RAS_entry)
or die Win32::RASE::FormatMessage;

print "UserName: ".($UserName ? $UserName : "<not defined>")."\n";
print "Password: ".($Password ? $Password : "<not defined>")."\n";

exit;

#----------- test of RasGetEntryDialParams ---------------
print "First RAS entry: $first_RAS_entry\n";

($UserName, $Password, $Domain, $CallbackNumber) =
RasGetEntryDialParams($first_RAS_entry)
or die Win32::RASE::FormatMessage;

print "UserName: ".($UserName ? $UserName : "<not defined>")."\n";
print "Password: ".($Password ? $Password : "<not defined>")."\n";
print "Domain : ".($Domain ? $Domain : "<not defined>")."\n";
print "CallbackNumber: ".($CallbackNumber ? $CallbackNumber : "<not defined>")."\n";

exit;

#----------- test of RasCreateEntryDlg ---------------
%old = map {$_,1} RasEnumEntries();

RasCreateEntryDlg($hwnd)
or die Win32::RASE::FormatMessage;

%new = map {$_,1} grep ! exists $old{$_}, RasEnumEntries();

if (keys %new) {
print "New entry `".((keys %new)[0])."' was created\n";
} else {
print "Success. No new entries were created.\n";
}

exit;

#----------- test of RasEditEntryDlg ---------------
print "First RAS entry: $first_RAS_entry\n";

RasEditEntryDlg($first_RAS_entry, $hwnd)
or die Win32::RASE::FormatMessage;

print "Edited successfully\n";

exit;

#----------- test of RasDialDlg ---------------
print "First RAS entry: $first_RAS_entry\n";

if ( RasDialDlg($first_RAS_entry, $hwnd) ) {
print "Connection established\n";
} elsif ( !Win32::RASE::GetLastError ) {
print "User selected <Cancel>\n";
} else {
warn Win32::RASE::FormatMessage, "\n";
}
exit;

#----------- test of TAPISetCurrentLocation ---------------
TAPISetCurrentLocation("Hotel")
or print "Location \"Hotel\" not found\n";
exit;


#----------- test of TAPIEnumLocations ---------------
($CurrentLocation, %locations) = Win32::RASE::TAPIEnumLocations;
print "Current Location: $CurrentLocation\n";
print map "$_ => [".(join", ",@{$locations{$_}})."]\n", keys %locations;
exit;


#----------- test of TAPIEnumerationPrint ---------------
Win32::RASE::TAPIEnumerationPrint();
exit;


#----------- test of IsCountryID ---------------
$CountryID = 112;
if ( IsCountryID($CountryID) ) {
print "$CountryID - valid CountryID\n";
} else {
print "$CountryID - invalid CountryID\n";
}
exit;

#----------- test of TAPICountryCode ---------------
$CountryID = 112;
if ($code = Win32::RASE::TAPICountryCode($CountryID)) {
print "$CountryID: code ($code) - ".Win32::RASE::TAPICountryName($CountryID)."\n";
} else {
print "Invalid CountryID\n";
}
exit;

#----------- test of TAPICountryName ---------------
if ($name = Win32::RASE::TAPICountryName(113)) {
print "$name\n";
} else {
print "Invalid CountryID\n";
}
exit;

#----------- test of TAPIlineGetTranslateCaps ---------------
($id, $code, $area) = Win32::RASE::TAPIlineGetTranslateCaps();
print "CountryID: $id\nCountryCode: $code\nAreaCode: $area\n";
exit;

#----------- test of RasEnumDevicesByType -- find modem device IDs ----
@modem_names = RasEnumDevicesByType("modem");
print @modem_names." modem(s) found\n";
exit;

#----------- test of RasEnumDevices ---------------
%devices = RasEnumDevices();
print map "\"$_\" of type \"$devices{$_}\"\n", keys %devices;
exit;

#----------- test of Win32::RASE::FormatMessage ---------------
print Win32::RASE::FormatMessage(630);
exit;

#----------- list of Ras errors ---------------
print map "$_ => ".Win32::RASE::FormatMessage($_)."\n", 600..752;
exit;


#=============== don't edit under this line ==============
sub FindOpenedFolders () {
# returns array of hwnd's of the opened folders
my $findAfter = 0;
my @folders;
$FindWindowEx ||= new Win32::API("user32", "FindWindowEx", [N,N,P,P], N);

while($findAfter = $FindWindowEx->Call(0, $findAfter, "CabinetWClass", 0)) {
push @folders, $findAfter;
}

$findAfter = 0;
while($findAfter = $FindWindowEx->Call(0, $findAfter, "ExploreWClass", 0)) {
push @folders, $findAfter;
}
@folders;
}

sub CloseWindow ($) {
# arg - hwnd
$PostMessage ||= new Win32::API("user32", "PostMessage", [N,N,N,N], I);
$WN_CLOSE = 0x10;

$PostMessage->Call(shift, $WN_CLOSE, 0, 0);
}

BEGIN {
require Win32::API;

unless ($hwnd = (FindOpenedFolders())[0]) {
system 'start explorer /n,C:\\';
$start_time = time;
while (!($hwnd = (FindOpenedFolders())[0]) && $start_time+3 < time) {}

$hwnd or die "Could not open C:\\ window\n";
$hwnd_opened = 1;
}

$first_RAS_entry = (RasEnumEntries())[0]
or die "No one RAS entry were found\n";
}

END { CloseWindow($hwnd) if $hwnd_opened }
 
J

Jay Tilton

: This is a multi-part message in MIME format.

And that multi-part message included four THOUSAND lines of code swiped
directly from the Win32::RASE distribution.

Don't do that again, blockhead.

: Bill wrote:
:
: > Win32::RASE, eg ppm install Win32::RASE or so forth
:
: This module is not on ActiveState, its only on CPAN. I Downloaded the
: Module from CPAN. I Raad the README file, which says, that should work
: also if only copied in @INC.

But you copied it into the wrong place.

Use the normal module installation procedure. The steps are listed in
that same README.

perl Makefile.PL
make
make test
make install

: I've done it but wenn I run an example
: script I recieve the following error:
:
: Win32::RASE::TAPIlineGetTranslateCaps() called too early to check
: prototype at c:/Perl/lib/RASE.pm line 266.
^^^^^^^^^^^^^^^^^^^
The path/filename needs to be c:/Perl/lib/Win32/RASE.pm
 
X

Xaver Biton

Jay said:
But you copied it into the wrong place.

Use the normal module installation procedure. The steps are listed in
that same README.

perl Makefile.PL
make
make test
make install

: I've done it but wenn I run an example
: script I recieve the following error:
:
: Win32::RASE::TAPIlineGetTranslateCaps() called too early to check
: prototype at c:/Perl/lib/RASE.pm line 266.
^^^^^^^^^^^^^^^^^^^
The path/filename needs to be c:/Perl/lib/Win32/RASE.pm

I've tried it before coping the module by hand in the usual way;


perl Makefile.PL
make
make test
make install

but by make it give me an error:
Makefile:299 *** multiple target patterns. Stop.

what is that?

thks.

Xaver
 
B

Ben Morrow

Xaver Biton said:
Jay Tilton wrote:

I've tried it before coping the module by hand in the usual way;

perl Makefile.PL
make
make test
make install

but by make it give me an error:
Makefile:299 *** multiple target patterns. Stop.

what is that?

Are you using cygwin make? For AS Perl you probably need M$ nmake
(free download from M$), unless you mess with the configuration.

Ben
 
X

Xaver Biton

but by make it give me an error:
Are you using cygwin make? For AS Perl you probably need M$ nmake
(free download from M$), unless you mess with the configuration.

ok, now, I've compiled it sucsessful with nmake, but I've alway the same
error as it was istalled manually. when I run the script example.pl I
recieve the error message:

Win32::RASE::TAPIlineGetTranslateCaps() called too early to check
prototype at c:/Perl/site/lib/Win32/RASE.pm line 266.
No one RAS entry were found
BEGIN failed--compilation aborted at examples.pl line 500.

The line 500 is a correctly closed curly bracket.

BEGIN {
require Win32::API;

unless ($hwnd = (FindOpenedFolders())[0]) {
system 'start explorer /n,C:\\';
$start_time = time;
while (!($hwnd = (FindOpenedFolders())[0]) && $start_time+3 < time) {}

$hwnd or die "Could not open C:\\ window\n";
$hwnd_opened = 1;
}

$first_RAS_entry = (RasEnumEntries())[0]
or die "No one RAS entry were found\n";
} ##this is the line 500

whats happend whit it?

Thks.

Xaver
 
B

Bill

Xaver said:
ok, now, I've compiled it sucsessful with nmake, but I've alway the same
error as it was istalled manually. when I run the script example.pl I
recieve the error message:

Win32::RASE::TAPIlineGetTranslateCaps() called too early to check
prototype at c:/Perl/site/lib/Win32/RASE.pm line 266.
No one RAS entry were found
BEGIN failed--compilation aborted at examples.pl line 500.

Yes, there is a prototypo :) in this one, probably older perl version.
try this--it works here:

#!/usr/bin/perl

# FIRST edit line 3031 of RASE.pm to remove the () to kill the error
# with current perl compiler.

use strict;
use warnings;
use Win32::RASE qw 'RasCreateEntry';

my %properties = (
name => 'Mydialer',
LocalPhoneNumber => '555-1212',
AreaCode => '800',
NetProtocols => ['Ip'],
FramingProtocol => 'PPP',
DeviceName => 'Standard 28800 bps Modem'
);

my $props = \%properties;
RasCreateEntry( $props ) or die "Could not make the entry work: $!";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top