Author Topic: Making a password system  (Read 22575 times)

Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
Making a password system
« on: October 10, 2013, 03:01:33 PM »
How would I open a file, read a line from it, close it, get user input, and then check to see if the two are the same? I know how to in c++ if that helps.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Making a password system
« Reply #1 on: October 10, 2013, 03:24:59 PM »
What OS? If this for your "text OS", you're going to need a filesystem  first. If you know the head/cylinder/sector, you can read it with int 13h (if you're still in real mode). Otherwise, you're going to need to write a heap of code.

If for some existing OS, which one? It matters.

Best,
Frank


Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
Re: Making a password system
« Reply #2 on: October 10, 2013, 10:56:16 PM »
Who says it is for an OS? I am just looking for some code. I am using nasm of course.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Making a password system
« Reply #3 on: October 10, 2013, 11:25:00 PM »
Okay, what filesystem does this mystery OS - or not - use?

Best,
Frank


Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
Re: Making a password system
« Reply #4 on: October 11, 2013, 03:25:48 PM »
Who says it is for an OS? The file with the password would be a text file.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Making a password system
« Reply #5 on: October 11, 2013, 03:43:31 PM »
What makes it a "text fie"? I understand that it has text in it, but what makes it a "file"?

Best,
Frank


Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
Re: Making a password system
« Reply #6 on: October 11, 2013, 05:50:55 PM »
password.txt would be the file.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Making a password system
« Reply #7 on: October 11, 2013, 06:52:28 PM »
Yes, but what makes it a "file"? The answer depends on "what OS?". If you don't know or won't say "what OS?", you'd better stick to C++.

Best,
Frank


Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
Re: Making a password system
« Reply #8 on: October 12, 2013, 12:48:25 PM »
Fine my text based one which would be loaded using virtual box and on a virtual hard drive.

Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
Re: Making a password system
« Reply #9 on: October 12, 2013, 03:17:29 PM »
The virtual hard drive would have password.txt on it.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Making a password system
« Reply #10 on: October 12, 2013, 06:48:28 PM »
Okay, now we're getting somewhere!

Your virtual hard drive "probably" doesn't have a filesystem on it - I would guess - unless you've put one there. This means you're up against head/cylinder/sector. If you put your password information immediately after your bootsector - in sector 2 - this shouldn't be too difficult. It won't give you a "named file" though.

I have a bootsector written by Deb Wiles (she helped a lot with the Nasm Manual). It parses a FAT12 filesystem and loads the named file "loader.bin" into memory. IF you can convince virtual box to format your virtual hard drive as FAT12, it should be fairly easy to modify this to load "password.txt" instead of "loader.bin". Note that directory entries (in FAT12) are all uppercase and the "." is not stored - the "first name" is space-padded to 8 bytes, followed by the three byte extension. Debs' filename is "LOADER  BIN", your filename will be "PASSWORDTXT" - or you could rename it to "loader.bin". :)

Keep in mind that I did not write this myself, and I haven't looked at it for a long time, so it may take me a while to get "oriented" before I can help you with it. I think this has been modified from Debs' original bootsector. It's what I've got.
Code: [Select]
deleted, drat it!

I don't know what the capabilities of virtual box are - you'll have to tell me. If it balks (pun) at formatting your virtual hard drive as FAT12, maybe it'll do FAT16. That might be even easier. FAT32 is tougher since we don't know the size of the root directory in advance. Maybe just ASSume that it isn't too big and will fit. These are all obsolete filesystems. I don't know the specifications for NTFS (or any of the Linux filesystems, which I assume you won't be using). NTFS was not well documented originally, but I think it is now. You'll have to look it up. Pray it'll do FAT12!

Are you still using "MikeOS" as an example to go by? How far have you gotten with it? If you've already loaded a "kernel", you may want to put this filesystem stuff in your kernel instead of squeezing it into a 512 byte bootsector. Up to you, it's "YourOS" now...

I hope you find the above useful... or at least understand why I want to know "what OS?"/"what filesystem?" before I can tell you how to open a file. If I haven't mentioned it, http://www.osdev.org has a lot of documentation you may find useful!

Best,
Frank

Well, curses - the Forum advises me that this message is too long! Lemme try to attach the code instead...



Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
Re: Making a password system
« Reply #11 on: October 15, 2013, 05:06:39 PM »
How would I create a bootsector? All I have is bootloader code.

Offline nullptr

  • Jr. Member
  • *
  • Posts: 27
Re: Making a password system
« Reply #12 on: October 15, 2013, 07:38:52 PM »
hi toad1359,
follow that link:
http://forum.osdev.org/

this is OS developers forum. You don't have to even ask just use the search bar and you will surely find what you need and much more.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Making a password system
« Reply #13 on: October 15, 2013, 08:28:32 PM »
Well, I guess it's a matter of terminology. My answer would be "it's the same thing". I guess some people refer to the first sector as a "bootsector" and what I would call a "second stage loader" as the "bootloader". More info here:

http://wiki.osdev.org/Bootloader

In any case, the first thing you want to do is:
Code: [Select]
nasm -f bin boot11.asm -o boot.bin

Now you've created a "bootsector". If you had a real floppy drive, you'd put a real floppy disk into it, format it if it isn't already formatted ("format a:"), copy some file named "loader.bin" to it, and write "boot.bin" to sector 1. "Copy" won't do this. John Fine's "partcopy" used to be popular, or "rawwrite", or DEBUG will do it. Then reboot your machine, telling the BIOS setup that you want to boot from "drive a:" if it isn't already set to do so.

I ASSume what you want to do is to "fool" virtual box into thinking that's what you did, if possible. If it isn't possible, you'll have to modify the code to comply with what it will do. I'm not familiar with virtual box, so you'll have to tell me about it. What does it say in the manual? (you have read the manual, right?) What did you do? What happened?

We've got a general rule on the Forum: "the less they give us, the less we give them". In other words, if you (this means "everybody" not just "you" personally) expect us to "give me the code" you aren't likely to get what you want. If you can show that you've put some effort into it and tried to solve the problem, we'll bend over backwards to help you. Before we can possibly help you, we need to know:
1) what are you trying to do (OS, other tools besides Nasm, etc.)
2) exactly what did you do?
3) what did you "expect" (hope) would happen?
4) what actually happened? (exact error message(s), no output, "garbage" output, etc.)

So far, it's been "like pulling teeth" to get any information out of you. "Give us more" and we'll try to "give you more"!

Best,
Frank


Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
Re: Making a password system
« Reply #14 on: October 15, 2013, 09:50:44 PM »
Thanks, I will look at all of this.