This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#26 2012-10-24 08:27:17

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: /etc/hosts and fake domains..

Thanks about this. I didn't know! I can easily connect myself to Scratch now C:

About the program, I can make it in Panther. It's actually pretty easy when you know the location of the hosts file.

EDIT: Done! Although, you do have to disable Read Only and make the file editable by everyone, as my tests have conclueded. If you're making a program, you're going to have to make it want to run in Administator mode.

Last edited by DigiTechs (2012-10-24 08:53:44)


I'm back.
Maybe.

Offline

 

#27 2012-10-24 08:58:40

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: /etc/hosts and fake domains..

I'll make a screenshot of the Panther program I made, so you can see how I did it.


I'm back.
Maybe.

Offline

 

#28 2012-10-24 09:17:42

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: /etc/hosts and fake domains..

I've never worked with IO in C++,but I may make a program designed for modifying the hosts file as I actually want to learn C++.
EDIT: I just got it working, but I need to know how to make char variables hold more than one character >.< Here's my current code:

#include "CustomHostsGenerator.h"
using namespace std;
int main ( )
{
    char c;
    char v;
    cout<<"Please input your desired IP."<<endl;
    cout<<"i.e.: 192.168.0.1"<<endl;
    cin>>c;
    cout<<endl;
    cout<<"Now insert your desired hostname."<<endl;
    cout<<"ie.: 192.168.0.1 would be router.int"<<endl;
    cin>>v;
    cout<<endl;
    ofstream file;
    file.open("C:\\Windows\\System32\\drivers\\etc\\hosts", ios_base::app);
    file<<c<<"    "<<v;
    cout<<"Wrote "<<c<<"    "<<v<<" to the hosts file. Enjoy!";
    system("PAUSE");
    return 0;
};
What it does is, after you get to cin>>c; it only stores 1 character of the ip and then on cin>>v; it stores the 2nd character of the ip. I want it so I can enter as many characters as I want in the c char and the v char.

Last edited by DigiTechs (2012-10-24 11:39:27)


I'm back.
Maybe.

Offline

 

#29 2012-10-24 11:04:16

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: /etc/hosts and fake domains..

blob8108 wrote:

Magnie wrote:

You can change it all you want, but anyone outside your network (or that computer itself) won't be able to access domains through that method. My Dad has set up our network so you can type a computer's name (we name all our computers  tongue ) instead of the internal IP.

Can't you just use Bonjour/Zeroconf/Avahi? My Macbook automatically broadcasts itself as "hostname.local", for example...  smile

Hmm, forgot about the broadcasting... So at most it would affect the LAN.

Offline

 

#30 2012-10-24 11:42:07

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: /etc/hosts and fake domains..

Magnie wrote:

blob8108 wrote:

Magnie wrote:

You can change it all you want, but anyone outside your network (or that computer itself) won't be able to access domains through that method. My Dad has set up our network so you can type a computer's name (we name all our computers  tongue ) instead of the internal IP.

Can't you just use Bonjour/Zeroconf/Avahi? My Macbook automatically broadcasts itself as "hostname.local", for example...  smile

Hmm, forgot about the broadcasting... So at most it would affect the LAN.

What would affect the LAN? Bonjour also only works across the LAN, too.  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#31 2012-10-24 11:45:11

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: /etc/hosts and fake domains..

Does anyone know C++, as my code that I pasted above doesn't work.. *rage* Say I inputted the dragonthunder IP on my code, what I would see in the hosts file is
9 [tab] 6

Replace [tab] with an actual tab, that's what I see.

EDIT: The dragonthunder IP is 96.[etc], not 69.[etc]

Last edited by DigiTechs (2012-10-24 11:45:46)


I'm back.
Maybe.

Offline

 

#32 2012-10-24 11:48:22

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: /etc/hosts and fake domains..

DigiTechs wrote:

Does anyone know C++, as my code that I pasted above doesn't work.. *rage* Say I inputted the dragonthunder IP on my code, what I would see in the hosts file is
9 [tab] 6

Replace [tab] with an actual tab, that's what I see.

EDIT: The dragonthunder IP is 96.[etc], not 69.[etc]

Is it "char *c", "char c[]", or some combination of the two?

Disclaimer: I don't know any C.  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#33 2012-10-24 12:19:48

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: /etc/hosts and fake domains..

This seems useful.  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#34 2012-10-24 13:32:31

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: /etc/hosts and fake domains..

blob8108 wrote:

This seems useful.  smile

The problem is, it's in C, which is not C++. The syntax may be the same, but the way you define things and run things is totally different.
EDIT: Oh, and here's my code:
#include "CustomHostsGenerator.h"
using namespace std;
int main ( )
{
    char c;
    char v;
    cout<<"Please input your desired IP."<<endl;
    cout<<"i.e.: 192.168.0.1"<<endl;
    cin>>c;
    cout<<endl;
    cout<<"Now insert your desired hostname."<<endl;
    cout<<"ie.: 192.168.0.1 would be router.int"<<endl;
    cin>>v;
    cout<<endl;
    ofstream file;
    file.open("C:\\Windows\\System32\\drivers\\etc\\hosts", ios_base::app);
    file<<c<<"    "<<v;
    file.close( );
    cout<<"Wrote "<<c<<"    "<<v<<" to the hosts file. Enjoy!";
    system("PAUSE");
    return 0;
};

Last edited by DigiTechs (2012-10-24 13:33:06)


I'm back.
Maybe.

Offline

 

#35 2012-10-24 13:35:57

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: /etc/hosts and fake domains..

DigiTechs wrote:

blob8108 wrote:

This seems useful.  smile

The problem is, it's in C, which is not C++. The syntax may be the same, but the way you define things and run things is totally different.

Really? My understanding was that C++ is a superset of C, so all C commands work the same in C++ — and C++ just adds extra object-oriented stuff.


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#36 2012-10-24 13:38:08

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: /etc/hosts and fake domains..

blob8108 wrote:

DigiTechs wrote:

blob8108 wrote:

This seems useful.  smile

The problem is, it's in C, which is not C++. The syntax may be the same, but the way you define things and run things is totally different.

Really? My understanding was that C++ is a superset of C, so all C commands work the same in C++ — and C++ just adds extra object-oriented stuff.

Well, on the page they declared the functions with void, in C++; I have been doing int main ( ) - so yeah. I belive there's a difference.


I'm back.
Maybe.

Offline

 

#37 2012-10-24 13:45:09

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: /etc/hosts and fake domains..

DigiTechs wrote:

blob8108 wrote:

DigiTechs wrote:


The problem is, it's in C, which is not C++. The syntax may be the same, but the way you define things and run things is totally different.

Really? My understanding was that C++ is a superset of C, so all C commands work the same in C++ — and C++ just adds extra object-oriented stuff.

Well, on the page they declared the functions with void, in C++; I have been doing int main ( ) - so yeah. I belive there's a difference.

"void" and "int" are just the return type of the function... either are valid in both C and C++, afaik.


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#38 2012-10-24 13:47:47

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: /etc/hosts and fake domains..

blob8108 wrote:

DigiTechs wrote:

blob8108 wrote:


Really? My understanding was that C++ is a superset of C, so all C commands work the same in C++ — and C++ just adds extra object-oriented stuff.

Well, on the page they declared the functions with void, in C++; I have been doing int main ( ) - so yeah. I belive there's a difference.

"void" and "int" are just the return type of the function... either are valid in both C and C++, afaik.

Well, even if they are similar, I think of them as two different languages, as it is easier to write code for me when I think 'this is one language, and this is another.' - This excludes XML though, as you can write Lua in XML.


I'm back.
Maybe.

Offline

 

#39 2012-10-24 14:46:12

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: /etc/hosts and fake domains..

YAY. My C++ Custom Hosts generator program works. Is there any place I should upload it to that allow you to do it for free? I'm thinking pastebin, but then you would need to compile it yourself.


I'm back.
Maybe.

Offline

 

#40 2012-10-24 16:06:04

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: /etc/hosts and fake domains..

Thanks for making it. Do you mind me using some components for my program, which downloads entries off my server?


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#41 2012-10-24 17:34:28

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: /etc/hosts and fake domains..

No, I don't mind at all! I made an official thread for it, so if you want to look at it - look at my thread.


I'm back.
Maybe.

Offline

 

#42 2012-10-24 17:49:09

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: /etc/hosts and fake domains..

Also bobbybee, as I am a complete newbie to C++ and C, I would like to help.
Although, it may be awkeward (Is that spelled right o.o?) that I program in C++, and not C which is what you program in.


I'm back.
Maybe.

Offline

 

#43 2012-10-24 18:12:43

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: /etc/hosts and fake domains..

awkward, firstly. And it's only subtle differences.


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#44 2012-10-24 18:29:23

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: /etc/hosts and fake domains..

bobbybee wrote:

awkward, firstly. And it's only subtle differences.

Thanks for correcting me. And about the subtle differences, what do you mean? Do you mean like things such as variable declaration?


I'm back.
Maybe.

Offline

 

#45 2012-10-24 21:28:27

pwiter
Scratcher
Registered: 2010-06-02
Posts: 100+

Re: /etc/hosts and fake domains..

pwiter wrote:

pwiter wrote:

Can I help?

Ahem....


http://i.imgur.com/YBeXc.png

Offline

 

#46 2012-10-25 15:52:23

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: /etc/hosts and fake domains..

Well, I'd prefer to do it myself, for organizational reasons.


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#47 2012-10-27 15:17:11

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: /etc/hosts and fake domains..

Cool. Is there any way to make a fake domain that redirects to a real one?

Last edited by technoboy10 (2012-10-27 15:17:19)


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#48 2012-10-27 16:29:48

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: /etc/hosts and fake domains..

Not really...


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#49 2012-10-27 17:50:43

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: /etc/hosts and fake domains..

bobbybee wrote:

Not really...

Okay.


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#50 2012-10-28 05:26:50

moretzprogramming
Scratcher
Registered: 2012-04-25
Posts: 61

Re: /etc/hosts and fake domains..

technoboy10 wrote:

Cool. Is there any way to make a fake domain that redirects to a real one?

Actually, you probably could. Just use some redirect code(there's one somewhere at w3schools.com), and put it at the IP address that you set the fake domain to use. It will redirect you to the real domain.


Check out my music, Noise Dots (in flash), and my Upside-Down Cat!

Offline

 

Board footer